diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 1eb9c19adec..6d98286b6ae 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -588,6 +588,24 @@ declare namespace vscode { Underline = 3 } + /** + * Rendering style of the line numbers. + */ + export enum TextEditorLineNumbersStyle { + /** + * Do not render the line numbers. + */ + Off = 0, + /** + * Render the line numbers. + */ + On = 1, + /** + * Render the line numbers with values relative to the primary cursor location. + */ + Relative = 2 + } + /** * Represents a [text editor](#TextEditor)'s [options](#TextEditor.options). */ @@ -622,7 +640,7 @@ declare namespace vscode { * When getting a text editor's options, this property will always be present. * When setting a text editor's options, this property is optional. */ - lineNumbers?: boolean | 'relative'; + lineNumbers?: TextEditorLineNumbersStyle; } /** diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 1f0b80ffa12..d38d53cc47a 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -86,6 +86,7 @@ export class ExtHostAPIImplementation { EndOfLine: typeof vscode.EndOfLine; TextDocumentSaveReason: typeof vscode.TextDocumentSaveReason; TextEditorCursorStyle: typeof vscode.TextEditorCursorStyle; + TextEditorLineNumbersStyle: typeof vscode.TextEditorLineNumbersStyle; TextEditorSelectionChangeKind: typeof vscode.TextEditorSelectionChangeKind; commands: typeof vscode.commands; window: typeof vscode.window; @@ -169,6 +170,7 @@ export class ExtHostAPIImplementation { this.TextEditorRevealType = extHostTypes.TextEditorRevealType; this.EndOfLine = extHostTypes.EndOfLine; this.TextEditorCursorStyle = EditorCommon.TextEditorCursorStyle; + this.TextEditorLineNumbersStyle = extHostTypes.TextEditorLineNumbersStyle; this.TextEditorSelectionChangeKind = extHostTypes.TextEditorSelectionChangeKind; this.TextDocumentSaveReason = extHostTypes.TextDocumentSaveReason; diff --git a/src/vs/workbench/api/node/extHostTypes.ts b/src/vs/workbench/api/node/extHostTypes.ts index 8fa4f72f48b..a1ce182b039 100644 --- a/src/vs/workbench/api/node/extHostTypes.ts +++ b/src/vs/workbench/api/node/extHostTypes.ts @@ -825,6 +825,12 @@ export enum EndOfLine { CRLF = 2 } +export enum TextEditorLineNumbersStyle { + Off = 0, + On = 1, + Relative = 2 +} + export enum TextDocumentSaveReason { Explicit = 1, Auto = 2, diff --git a/src/vs/workbench/api/node/mainThreadEditorsTracker.ts b/src/vs/workbench/api/node/mainThreadEditorsTracker.ts index 7e7d8750032..55c66278d50 100644 --- a/src/vs/workbench/api/node/mainThreadEditorsTracker.ts +++ b/src/vs/workbench/api/node/mainThreadEditorsTracker.ts @@ -14,19 +14,19 @@ import {RunOnceScheduler} from 'vs/base/common/async'; import {IdGenerator} from 'vs/base/common/idGenerator'; import {Range} from 'vs/editor/common/core/range'; import {Selection} from 'vs/editor/common/core/selection'; -import {EndOfLine} from 'vs/workbench/api/node/extHostTypes'; +import {EndOfLine, TextEditorLineNumbersStyle} from 'vs/workbench/api/node/extHostTypes'; export interface ITextEditorConfigurationUpdate { tabSize?: number | string; insertSpaces?: boolean | string; cursorStyle?: EditorCommon.TextEditorCursorStyle; - lineNumbers?: boolean | 'relative'; + lineNumbers?: TextEditorLineNumbersStyle; } export interface IResolvedTextEditorConfiguration { tabSize: number; insertSpaces: boolean; cursorStyle: EditorCommon.TextEditorCursorStyle; - lineNumbers: boolean | 'relative'; + lineNumbers: TextEditorLineNumbersStyle; } function configurationsEqual(a:IResolvedTextEditorConfiguration, b:IResolvedTextEditorConfiguration) { @@ -263,8 +263,19 @@ export class MainThreadTextEditor { return; } + let lineNumbers: true | false | 'relative'; + switch (newConfiguration.lineNumbers) { + case TextEditorLineNumbersStyle.On: + lineNumbers = true; + break; + case TextEditorLineNumbersStyle.Relative: + lineNumbers = 'relative'; + break; + default: + lineNumbers = false; + } this._codeEditor.updateOptions({ - lineNumbers: newConfiguration.lineNumbers + lineNumbers: lineNumbers }); } } @@ -299,17 +310,17 @@ export class MainThreadTextEditor { return this._configuration; } let cursorStyle = this._configuration ? this._configuration.cursorStyle : EditorCommon.TextEditorCursorStyle.Line; - let lineNumbers: boolean | 'relative' = this._configuration ? this._configuration.lineNumbers : true; + let lineNumbers: TextEditorLineNumbersStyle = this._configuration ? this._configuration.lineNumbers : TextEditorLineNumbersStyle.On; if (codeEditor) { let codeEditorOpts = codeEditor.getConfiguration(); cursorStyle = codeEditorOpts.viewInfo.cursorStyle; if (codeEditorOpts.viewInfo.renderRelativeLineNumbers) { - lineNumbers = 'relative'; + lineNumbers = TextEditorLineNumbersStyle.Relative; } else if (codeEditorOpts.viewInfo.renderLineNumbers) { - lineNumbers = true; + lineNumbers = TextEditorLineNumbersStyle.On; } else { - lineNumbers = false; + lineNumbers = TextEditorLineNumbersStyle.Off; } }