diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 93db9989b4da14b439f43229058c42f8e4d92a07..1eb9c19adec513e4fc570101508a051e52834d77 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -616,6 +616,13 @@ declare namespace vscode { * When setting a text editor's options, this property is optional. */ cursorStyle?: TextEditorCursorStyle; + + /** + * Render relative line numbers w.r.t. the current line number. + * 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'; } /** diff --git a/src/vs/workbench/api/node/mainThreadEditorsTracker.ts b/src/vs/workbench/api/node/mainThreadEditorsTracker.ts index c466544950f1b30e105423c26a9705d15cdb87c1..7e7d87500323d421e30fc9a89f869d0fce72c595 100644 --- a/src/vs/workbench/api/node/mainThreadEditorsTracker.ts +++ b/src/vs/workbench/api/node/mainThreadEditorsTracker.ts @@ -20,11 +20,13 @@ export interface ITextEditorConfigurationUpdate { tabSize?: number | string; insertSpaces?: boolean | string; cursorStyle?: EditorCommon.TextEditorCursorStyle; + lineNumbers?: boolean | 'relative'; } export interface IResolvedTextEditorConfiguration { tabSize: number; insertSpaces: boolean; cursorStyle: EditorCommon.TextEditorCursorStyle; + lineNumbers: boolean | 'relative'; } function configurationsEqual(a:IResolvedTextEditorConfiguration, b:IResolvedTextEditorConfiguration) { @@ -253,6 +255,18 @@ export class MainThreadTextEditor { cursorStyle: newCursorStyle }); } + + if (typeof newConfiguration.lineNumbers !== 'undefined') { + + if (!this._codeEditor) { + console.warn('setConfiguration on invisible editor'); + return; + } + + this._codeEditor.updateOptions({ + lineNumbers: newConfiguration.lineNumbers + }); + } } public setDecorations(key: string, ranges:EditorCommon.IDecorationOptions[]): void { @@ -285,16 +299,26 @@ 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; if (codeEditor) { let codeEditorOpts = codeEditor.getConfiguration(); cursorStyle = codeEditorOpts.viewInfo.cursorStyle; + + if (codeEditorOpts.viewInfo.renderRelativeLineNumbers) { + lineNumbers = 'relative'; + } else if (codeEditorOpts.viewInfo.renderLineNumbers) { + lineNumbers = true; + } else { + lineNumbers = false; + } } let indent = model.getOptions(); return { insertSpaces: indent.insertSpaces, tabSize: indent.tabSize, - cursorStyle: cursorStyle + cursorStyle: cursorStyle, + lineNumbers: lineNumbers }; }