提交 a33f2a23 编写于 作者: I Isidor Nikolic 提交者: GitHub

Merge pull request #20660 from michelkaporin/lineNumber-configuration

Line number configuration fixes #12714
......@@ -13,6 +13,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { toResource } from 'vs/workbench/common/editor';
......@@ -77,6 +78,19 @@ export class ConfigurationResolverService implements IConfigurationResolverServi
return paths.extname(this.getFilePath());
}
private get lineNumber(): string {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const editorControl = (<ICommonCodeEditor>activeEditor.getControl());
if (editorControl) {
const lineNumber = editorControl.getSelection().positionLineNumber;
return String(lineNumber);
}
}
return '';
}
private getFilePath(): string {
let input = this.editorService.getActiveEditorInput();
if (!input) {
......
......@@ -41,6 +41,10 @@ suite('Configuration Resolver Service', () => {
assert.strictEqual(configurationResolverService.resolve('abc ${workspaceRootFolderName} xyz'), 'abc workspaceLocation xyz');
});
test('current selected line number', () => {
assert.strictEqual(configurationResolverService.resolve('abc ${lineNumber} xyz'), 'abc 15 xyz');
});
test('substitute many', () => {
if (platform.isWindows) {
assert.strictEqual(configurationResolverService.resolve('${workspaceRoot} - ${workspaceRoot}'), '\\VSCode\\workspaceLocation - \\VSCode\\workspaceLocation');
......
......@@ -498,7 +498,19 @@ export class TestEditorService implements IWorkbenchEditorService {
public getActiveEditor(): IEditor {
this.callback('getActiveEditor');
return null;
return {
input: null,
options: null,
position: null,
getId: () => { return null; },
getControl: () => {
return {
getSelection: () => { return { positionLineNumber: 15 }; }
};
},
focus: () => { },
isVisible: () => { return true; }
};
}
public getActiveEditorInput(): IEditorInput {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册