diff --git a/src/sql/parts/modelComponents/queryTextEditor.ts b/src/sql/parts/modelComponents/queryTextEditor.ts index 49d3925922..bef16ded19 100644 --- a/src/sql/parts/modelComponents/queryTextEditor.ts +++ b/src/sql/parts/modelComponents/queryTextEditor.ts @@ -37,6 +37,7 @@ export class QueryTextEditor extends BaseTextEditor { private _config: editorCommon.IConfiguration; private _minHeight: number; private _selected: boolean; + private _hideLineNumbers: boolean; private _editorWorkspaceConfig; private _scrollbarHeight: number; constructor( @@ -78,6 +79,9 @@ export class QueryTextEditor extends BaseTextEditor { if (!this._selected) { options.renderLineHighlight = 'none'; } + if (this._hideLineNumbers) { + options.lineNumbers = 'off'; + } } return options; } @@ -169,6 +173,11 @@ export class QueryTextEditor extends BaseTextEditor { this.refreshEditorConfguration(); } + public set hideLineNumbers(value: boolean) { + this._hideLineNumbers = value; + this.refreshEditorConfguration(); + } + private refreshEditorConfguration(configuration = this.configurationService.getValue(this.getResource())): void { if (!this.getControl()) { return; diff --git a/src/sql/parts/notebook/cellViews/code.component.ts b/src/sql/parts/notebook/cellViews/code.component.ts index 400dfbd916..28adb4e17b 100644 --- a/src/sql/parts/notebook/cellViews/code.component.ts +++ b/src/sql/parts/notebook/cellViews/code.component.ts @@ -31,8 +31,11 @@ import { IModelService } from 'vs/editor/common/services/modelService'; import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { CellTypes } from 'sql/parts/notebook/models/contracts'; +import { OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService'; export const CODE_SELECTOR: string = 'code-component'; +const MARKDOWN_CLASS = 'markdown'; @Component({ selector: CODE_SELECTOR, @@ -42,7 +45,18 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange @ViewChild('toolbar', { read: ElementRef }) private toolbarElement: ElementRef; @ViewChild('moreactions', { read: ElementRef }) private moreActionsElementRef: ElementRef; @ViewChild('editor', { read: ElementRef }) private codeElement: ElementRef; - @Input() cellModel: ICellModel; + + public get cellModel(): ICellModel { + return this._cellModel; + } + + @Input() public set cellModel(value: ICellModel) { + this._cellModel = value; + if (this.toolbarElement && value && value.cellType === CellTypes.Markdown) { + let nativeToolbar = this.toolbarElement.nativeElement; + DOM.addClass(nativeToolbar, MARKDOWN_CLASS); + } + } @Output() public onContentChanged = new EventEmitter(); @@ -62,13 +76,12 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange } } - protected _actionBar: Taskbar; private readonly _minimumHeight = 30; + private _cellModel: ICellModel; private _editor: QueryTextEditor; private _editorInput: UntitledEditorInput; private _editorModel: ITextModel; - private _uri: string; private _model: NotebookModel; private _activeCellId: string; private _cellToggleMoreActions: CellToggleMoreActions; @@ -143,6 +156,10 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange let isActive = this.cellModel.id === this._activeCellId; this._editor.toggleEditorSelected(isActive); + // For markdown cells, don't show line numbers unless we're using editor defaults + let overrideEditorSetting = this._configurationService.getValue(OVERRIDE_EDITOR_THEMING_SETTING); + this._editor.hideLineNumbers = (overrideEditorSetting && this.cellModel.cellType === CellTypes.Markdown); + this._register(this._editor); this._register(this._editorInput); this._register(this._editorModel.onDidChangeContent(e => { diff --git a/src/sql/parts/notebook/cellViews/code.css b/src/sql/parts/notebook/cellViews/code.css index 6599792faa..1ac39fac02 100644 --- a/src/sql/parts/notebook/cellViews/code.css +++ b/src/sql/parts/notebook/cellViews/code.css @@ -19,6 +19,10 @@ code-component .toolbar { orientation: portrait } +code-component .toolbar.markdown { + display: none; +} + code-component .toolbar .carbon-taskbar { position: sticky; top: 0px; diff --git a/src/sql/workbench/services/notebook/common/notebookService.ts b/src/sql/workbench/services/notebook/common/notebookService.ts index 351d23036f..b47476f35d 100644 --- a/src/sql/workbench/services/notebook/common/notebookService.ts +++ b/src/sql/workbench/services/notebook/common/notebookService.ts @@ -24,6 +24,7 @@ export const INotebookService = createDecorator(SERVICE_ID); export const DEFAULT_NOTEBOOK_PROVIDER = 'builtin'; export const DEFAULT_NOTEBOOK_FILETYPE = 'IPYNB'; export const SQL_NOTEBOOK_PROVIDER = 'sql'; +export const OVERRIDE_EDITOR_THEMING_SETTING = 'notebook.overrideEditorTheming'; export interface INotebookService { _serviceBrand: any; diff --git a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts index b9013254d6..b84fe01e91 100644 --- a/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts +++ b/src/sql/workbench/services/notebook/common/notebookServiceImpl.ts @@ -12,7 +12,7 @@ import { Registry } from 'vs/platform/registry/common/platform'; import { INotebookService, INotebookManager, INotebookProvider, DEFAULT_NOTEBOOK_PROVIDER, - DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER + DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook/common/notebookService'; import { RenderMimeRegistry } from 'sql/parts/notebook/outputs/registry'; import { standardRendererFactories } from 'sql/parts/notebook/outputs/factories'; @@ -39,8 +39,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur import { IThemeService } from 'vs/platform/theme/common/themeService'; import { registerNotebookThemes } from 'sql/parts/notebook/notebookStyles'; -const OVERRIDE_EDITOR_THEMING_SETTING = 'notebook.overrideEditorTheming'; - export interface NotebookProviderProperties { provider: string; fileExtensions: string[];