提交 fc962e0d 编写于 作者: I isidor

add decorations for launch.json

fixes microsoft/vscode#13353
上级 d34c873d
......@@ -7,12 +7,27 @@
import * as vscode from 'vscode';
import { getLocation } from 'jsonc-parser';
import * as path from 'path';
const decoration = vscode.window.createTextEditorDecorationType({
color: '#b1b1b1',
isWholeLine: true
});
export function activate(context) {
//keybindings.json command-suggestions
context.subscriptions.push(registerKeybindingsCompletions());
// launch.json decorations
context.subscriptions.push(vscode.window.onDidChangeActiveTextEditor(editor => updateLaunchJsonDecorations(editor), null, context.subscriptions));
context.subscriptions.push(vscode.workspace.onDidChangeTextDocument(event => {
if (vscode.window.activeTextEditor && event.document === vscode.window.activeTextEditor.document) {
console.log('hello there');
updateLaunchJsonDecorations(vscode.window.activeTextEditor);
}
}, null, context.subscriptions));
updateLaunchJsonDecorations(vscode.window.activeTextEditor);
}
function registerKeybindingsCompletions(): vscode.Disposable {
......@@ -31,6 +46,22 @@ function registerKeybindingsCompletions(): vscode.Disposable {
});
}
function updateLaunchJsonDecorations(editor: vscode.TextEditor) {
if (!editor || path.basename(editor.document.fileName) !== 'launch.json') {
return;
}
const ranges = [];
for (let i = 0; i < editor.document.lineCount; i++) {
const line = editor.document.lineAt(i);
if (line.text.indexOf('\"version\"') >= 0 || line.text.indexOf('\"type\"') >= 0 || line.text.indexOf('\"request\"') >= 0) {
ranges.push(new vscode.Range(line.range.start, line.range.start));
}
}
editor.setDecorations(decoration, ranges);
}
function newCompletionItem(text: string, range: vscode.Range, documentation?: string) {
const item = new vscode.CompletionItem(JSON.stringify(text));
item.kind = vscode.CompletionItemKind.Value;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册