Merge from vscode 591842cc4b71958c81947b254924a215fe3edcbd (#4886)

This commit is contained in:
Karl Burtram
2019-04-05 14:14:26 -07:00
committed by GitHub
parent 657adafb7d
commit 0532346f4f
117 changed files with 1691 additions and 1191 deletions

View File

@@ -3,12 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import * as vscode from 'vscode';
import { getLocation, visit, parse, ParseErrorCode } from 'jsonc-parser';
import { getLocation, parse, visit } from 'jsonc-parser';
import * as path from 'path';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { SettingsDocument } from './settingsDocumentHelper';
const localize = nls.loadMessageBundle();
const fadedDecoration = vscode.window.createTextEditorDecorationType({
light: {
@@ -45,50 +45,6 @@ export function activate(context: vscode.ExtensionContext): void {
}
}, null, context.subscriptions));
updateLaunchJsonDecorations(vscode.window.activeTextEditor);
context.subscriptions.push(vscode.workspace.onWillSaveTextDocument(e => {
if (!e.document.fileName.endsWith('/settings.json')) {
return;
}
autoFixSettingsJSON(e);
}));
}
function autoFixSettingsJSON(willSaveEvent: vscode.TextDocumentWillSaveEvent): void {
const document = willSaveEvent.document;
const text = document.getText();
const edit = new vscode.WorkspaceEdit();
let lastEndOfSomething = -1;
visit(text, {
onArrayEnd(offset: number, length: number): void {
lastEndOfSomething = offset + length;
},
onLiteralValue(_value: any, offset: number, length: number): void {
lastEndOfSomething = offset + length;
},
onObjectEnd(offset: number, length: number): void {
lastEndOfSomething = offset + length;
},
onError(error: ParseErrorCode, _offset: number, _length: number): void {
if (error === ParseErrorCode.CommaExpected && lastEndOfSomething > -1) {
const fixPosition = document.positionAt(lastEndOfSomething);
// Don't insert a comma immediately before a : or ' :'
const colonRange = document.getWordRangeAtPosition(fixPosition, / *:/);
if (!colonRange) {
edit.insert(document.uri, fixPosition, ',');
}
}
}
});
willSaveEvent.waitUntil(
vscode.workspace.applyEdit(edit));
}
function registerSettingsCompletions(): vscode.Disposable {

View File

@@ -6,7 +6,7 @@
"git": {
"name": "MagicStack/MagicPython",
"repositoryUrl": "https://github.com/MagicStack/MagicPython",
"commitHash": "8ff35b3e5fcde471fae62a57ea1ae1c7cd34c9fc"
"commitHash": "38422d302fe0b3e7716d26ce8cd7d0b9685f3a38"
}
},
"license": "MIT",

View File

@@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request."
],
"version": "https://github.com/MagicStack/MagicPython/commit/8ff35b3e5fcde471fae62a57ea1ae1c7cd34c9fc",
"version": "https://github.com/MagicStack/MagicPython/commit/38422d302fe0b3e7716d26ce8cd7d0b9685f3a38",
"name": "MagicPython",
"scopeName": "source.python",
"patterns": [
@@ -826,7 +826,7 @@
]
},
"f-expression": {
"comment": "All valid Python expressions, except comments and line cont",
"comment": "All valid Python expressions, except comments and line continuation",
"patterns": [
{
"include": "#expression-bare"