Remove gray attributes in launch.json since they are confusing
fixes #80026
This commit is contained in:
parent
485fdf8bea
commit
d5bc3ab7ee
1 changed files with 0 additions and 57 deletions
|
@ -4,23 +4,11 @@
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { getLocation, parse, visit } from 'jsonc-parser';
|
import { getLocation, parse, visit } from 'jsonc-parser';
|
||||||
import * as path from 'path';
|
|
||||||
import * as vscode from 'vscode';
|
import * as vscode from 'vscode';
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { SettingsDocument } from './settingsDocumentHelper';
|
import { SettingsDocument } from './settingsDocumentHelper';
|
||||||
const localize = nls.loadMessageBundle();
|
const localize = nls.loadMessageBundle();
|
||||||
|
|
||||||
const fadedDecoration = vscode.window.createTextEditorDecorationType({
|
|
||||||
light: {
|
|
||||||
color: '#757575'
|
|
||||||
},
|
|
||||||
dark: {
|
|
||||||
color: '#878787'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let pendingLaunchJsonDecoration: NodeJS.Timer;
|
|
||||||
|
|
||||||
export function activate(context: vscode.ExtensionContext): void {
|
export function activate(context: vscode.ExtensionContext): void {
|
||||||
//settings.json suggestions
|
//settings.json suggestions
|
||||||
context.subscriptions.push(registerSettingsCompletions());
|
context.subscriptions.push(registerSettingsCompletions());
|
||||||
|
@ -33,18 +21,6 @@ export function activate(context: vscode.ExtensionContext): void {
|
||||||
|
|
||||||
// task.json variable suggestions
|
// task.json variable suggestions
|
||||||
context.subscriptions.push(registerVariableCompletions('**/tasks.json'));
|
context.subscriptions.push(registerVariableCompletions('**/tasks.json'));
|
||||||
|
|
||||||
// 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) {
|
|
||||||
if (pendingLaunchJsonDecoration) {
|
|
||||||
clearTimeout(pendingLaunchJsonDecoration);
|
|
||||||
}
|
|
||||||
pendingLaunchJsonDecoration = setTimeout(() => updateLaunchJsonDecorations(vscode.window.activeTextEditor), 1000);
|
|
||||||
}
|
|
||||||
}, null, context.subscriptions));
|
|
||||||
updateLaunchJsonDecorations(vscode.window.activeTextEditor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerSettingsCompletions(): vscode.Disposable {
|
function registerSettingsCompletions(): vscode.Disposable {
|
||||||
|
@ -153,39 +129,6 @@ function provideInstalledExtensionProposals(extensionsContent: IExtensionsConten
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined): void {
|
|
||||||
if (!editor || path.basename(editor.document.fileName) !== 'launch.json') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ranges: vscode.Range[] = [];
|
|
||||||
let addPropertyAndValue = false;
|
|
||||||
let depthInArray = 0;
|
|
||||||
visit(editor.document.getText(), {
|
|
||||||
onObjectProperty: (property, offset, length) => {
|
|
||||||
// Decorate attributes which are unlikely to be edited by the user.
|
|
||||||
// Only decorate "configurations" if it is not inside an array (compounds have a configurations property which should not be decorated).
|
|
||||||
addPropertyAndValue = property === 'version' || property === 'type' || property === 'request' || property === 'compounds' || (property === 'configurations' && depthInArray === 0);
|
|
||||||
if (addPropertyAndValue) {
|
|
||||||
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLiteralValue: (_value, offset, length) => {
|
|
||||||
if (addPropertyAndValue) {
|
|
||||||
ranges.push(new vscode.Range(editor.document.positionAt(offset), editor.document.positionAt(offset + length)));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onArrayBegin: (_offset: number, _length: number) => {
|
|
||||||
depthInArray++;
|
|
||||||
},
|
|
||||||
onArrayEnd: (_offset: number, _length: number) => {
|
|
||||||
depthInArray--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
editor.setDecorations(fadedDecoration, ranges);
|
|
||||||
}
|
|
||||||
|
|
||||||
vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'jsonc' }, {
|
vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'jsonc' }, {
|
||||||
provideDocumentSymbols(document: vscode.TextDocument, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
|
provideDocumentSymbols(document: vscode.TextDocument, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
|
||||||
const result: vscode.SymbolInformation[] = [];
|
const result: vscode.SymbolInformation[] = [];
|
||||||
|
|
Loading…
Reference in a new issue