提交 2243f851 编写于 作者: B Benjamin Pasero

Merge branch 'master' into ben/editor

......@@ -695,9 +695,9 @@
]
},
"dependencies": {
"vscode-languageclient": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2",
"vscode-nls": "^3.2.1"
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-nls": "^3.2.2"
},
"devDependencies": {
"@types/node": "7.0.43"
......
......@@ -8,9 +8,9 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^3.0.9-next.14",
"vscode-languageserver": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2"
"vscode-css-languageservice": "^3.0.9-next.15",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1"
},
"devDependencies": {
"@types/mocha": "2.2.33",
......
......@@ -24,7 +24,7 @@ export interface Settings {
}
// Create a connection for the server.
let connection: IConnection = createConnection();
const connection: IConnection = createConnection();
console.log = connection.console.log.bind(connection.console);
console.error = connection.console.error.bind(connection.console);
......@@ -35,12 +35,12 @@ process.on('unhandledRejection', (e: any) => {
// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments = new TextDocuments();
const documents: TextDocuments = new TextDocuments();
// Make the text document manager listen on the connection
// for open, change and close text document events
documents.listen(connection);
let stylesheets = getLanguageModelCache<Stylesheet>(10, 60, document => getLanguageService(document).parseStylesheet(document));
const stylesheets = getLanguageModelCache<Stylesheet>(10, 60, document => getLanguageService(document).parseStylesheet(document));
documents.onDidClose(e => {
stylesheets.onDocumentRemoved(e.document);
});
......@@ -64,7 +64,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
}
function getClientCapability<T>(name: string, def: T) {
let keys = name.split('.');
const keys = name.split('.');
let c: any = params.capabilities;
for (let i = 0; c && i < keys.length; i++) {
if (!c.hasOwnProperty(keys[i])) {
......@@ -74,11 +74,11 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
}
return c;
}
let snippetSupport = !!getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
const snippetSupport = !!getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
scopedSettingsSupport = !!getClientCapability('workspace.configuration', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
let capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: snippetSupport ? { resolveProvider: false, triggerCharacters: ['/'] } : undefined,
......@@ -95,7 +95,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
return { capabilities };
});
let languageServices: { [id: string]: LanguageService } = {
const languageServices: { [id: string]: LanguageService } = {
css: getCSSLanguageService(),
scss: getSCSSLanguageService(),
less: getLESSLanguageService()
......@@ -119,7 +119,7 @@ function getDocumentSettings(textDocument: TextDocument): Thenable<LanguageSetti
if (scopedSettingsSupport) {
let promise = documentSettings[textDocument.uri];
if (!promise) {
let configRequestParam = { items: [{ scopeUri: textDocument.uri, section: textDocument.languageId }] };
const configRequestParam = { items: [{ scopeUri: textDocument.uri, section: textDocument.languageId }] };
promise = connection.sendRequest(ConfigurationRequest.type, configRequestParam).then(s => s[0]);
documentSettings[textDocument.uri] = promise;
}
......@@ -134,7 +134,7 @@ connection.onDidChangeConfiguration(change => {
});
function updateConfiguration(settings: Settings) {
for (let languageId in languageServices) {
for (const languageId in languageServices) {
languageServices[languageId].configure((settings as any)[languageId]);
}
// reset all document settings
......@@ -143,7 +143,7 @@ function updateConfiguration(settings: Settings) {
documents.all().forEach(triggerValidation);
}
let pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
const pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
const validationDelayMs = 500;
// The content of a text document has changed. This event is emitted
......@@ -159,7 +159,7 @@ documents.onDidClose(event => {
});
function cleanPendingValidation(textDocument: TextDocument): void {
let request = pendingValidationRequests[textDocument.uri];
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
delete pendingValidationRequests[textDocument.uri];
......@@ -175,10 +175,10 @@ function triggerValidation(textDocument: TextDocument): void {
}
function validateTextDocument(textDocument: TextDocument): void {
let settingsPromise = getDocumentSettings(textDocument);
const settingsPromise = getDocumentSettings(textDocument);
settingsPromise.then(settings => {
let stylesheet = stylesheets.get(textDocument);
let diagnostics = getLanguageService(textDocument).doValidation(textDocument, stylesheet, settings);
const stylesheet = stylesheets.get(textDocument);
const diagnostics = getLanguageService(textDocument).doValidation(textDocument, stylesheet, settings);
// Send the computed diagnostics to VSCode.
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
}, e => {
......@@ -188,14 +188,17 @@ function validateTextDocument(textDocument: TextDocument): void {
connection.onCompletion((textDocumentPosition, token) => {
return runSafe(() => {
let document = documents.get(textDocumentPosition.textDocument.uri);
const document = documents.get(textDocumentPosition.textDocument.uri);
if (!document) {
return null;
}
const cssLS = getLanguageService(document);
const pathCompletionList: CompletionList = {
isIncomplete: false,
items: []
};
cssLS.setCompletionParticipants([getPathCompletionParticipant(document, workspaceFolders, pathCompletionList)]);
const result = cssLS.doComplete(document, textDocumentPosition.position, stylesheets.get(document))!; /* TODO: remove ! once LS has null annotations */
const result = cssLS.doComplete(document, textDocumentPosition.position, stylesheets.get(document));
return {
isIncomplete: pathCompletionList.isIncomplete,
items: [...pathCompletionList.items, ...result.items]
......@@ -205,57 +208,76 @@ connection.onCompletion((textDocumentPosition, token) => {
connection.onHover((textDocumentPosition, token) => {
return runSafe(() => {
let document = documents.get(textDocumentPosition.textDocument.uri);
let styleSheet = stylesheets.get(document);
return getLanguageService(document).doHover(document, textDocumentPosition.position, styleSheet);
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const styleSheet = stylesheets.get(document);
return getLanguageService(document).doHover(document, textDocumentPosition.position, styleSheet);
}
return null;
}, null, `Error while computing hover for ${textDocumentPosition.textDocument.uri}`, token);
});
connection.onDocumentSymbol((documentSymbolParams, token) => {
return runSafe(() => {
let document = documents.get(documentSymbolParams.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).findDocumentSymbols(document, stylesheet);
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).findDocumentSymbols(document, stylesheet);
}
return [];
}, [], `Error while computing document symbols for ${documentSymbolParams.textDocument.uri}`, token);
});
connection.onDefinition((documentSymbolParams, token) => {
return runSafe(() => {
let document = documents.get(documentSymbolParams.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).findDefinition(document, documentSymbolParams.position, stylesheet);
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).findDefinition(document, documentSymbolParams.position, stylesheet);
}
return null;
}, null, `Error while computing definitions for ${documentSymbolParams.textDocument.uri}`, token);
});
connection.onDocumentHighlight((documentSymbolParams, token) => {
return runSafe(() => {
let document = documents.get(documentSymbolParams.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).findDocumentHighlights(document, documentSymbolParams.position, stylesheet);
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).findDocumentHighlights(document, documentSymbolParams.position, stylesheet);
}
return [];
}, [], `Error while computing document highlights for ${documentSymbolParams.textDocument.uri}`, token);
});
connection.onReferences((referenceParams, token) => {
return runSafe(() => {
let document = documents.get(referenceParams.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).findReferences(document, referenceParams.position, stylesheet);
const document = documents.get(referenceParams.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).findReferences(document, referenceParams.position, stylesheet);
}
return [];
}, [], `Error while computing references for ${referenceParams.textDocument.uri}`, token);
});
connection.onCodeAction((codeActionParams, token) => {
return runSafe(() => {
let document = documents.get(codeActionParams.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).doCodeActions(document, codeActionParams.range, codeActionParams.context, stylesheet);
const document = documents.get(codeActionParams.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).doCodeActions(document, codeActionParams.range, codeActionParams.context, stylesheet);
}
return [];
}, [], `Error while computing code actions for ${codeActionParams.textDocument.uri}`, token);
});
connection.onDocumentColor((params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
let stylesheet = stylesheets.get(document);
const stylesheet = stylesheets.get(document);
return getLanguageService(document).findDocumentColors(document, stylesheet);
}
return [];
......@@ -264,9 +286,9 @@ connection.onDocumentColor((params, token) => {
connection.onColorPresentation((params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
let stylesheet = stylesheets.get(document);
const stylesheet = stylesheets.get(document);
return getLanguageService(document).getColorPresentations(document, stylesheet, params.color, params.range);
}
return [];
......@@ -275,16 +297,22 @@ connection.onColorPresentation((params, token) => {
connection.onRenameRequest((renameParameters, token) => {
return runSafe(() => {
let document = documents.get(renameParameters.textDocument.uri);
let stylesheet = stylesheets.get(document);
return getLanguageService(document).doRename(document, renameParameters.position, renameParameters.newName, stylesheet);
const document = documents.get(renameParameters.textDocument.uri);
if (document) {
const stylesheet = stylesheets.get(document);
return getLanguageService(document).doRename(document, renameParameters.position, renameParameters.newName, stylesheet);
}
return null;
}, null, `Error while computing renames for ${renameParameters.textDocument.uri}`, token);
});
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
return getLanguageService(document).getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
const document = documents.get(params.textDocument.uri);
if (document) {
return getLanguageService(document).getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
}
return null;
}, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);
});
......
......@@ -10,43 +10,43 @@
version "7.0.43"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
vscode-css-languageservice@^3.0.9-next.14:
version "3.0.9-next.14"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.14.tgz#156822b2d8c56487ffd47105cc884fa3983664ca"
vscode-css-languageservice@^3.0.9-next.15:
version "3.0.9-next.15"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.15.tgz#67a91ed2cc7cf6ea46d45c2e9e9332c74df06ec5"
dependencies:
vscode-languageserver-types "^3.6.1"
vscode-nls "^3.2.1"
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0, vscode-languageserver-types@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz#4bc06a48dff653495f12f94b8b1e228988a1748d"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.0.0.tgz#8b792f0d6d10acfe363d02371ed4ce53d08af88a"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-nls@^3.2.1:
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
......
......@@ -6,34 +6,34 @@
version "7.0.43"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.0.0.tgz#635f5bfbcfa1385dae489b394857f1db8b459a7d"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz#4bc06a48dff653495f12f94b8b1e228988a1748d"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-nls@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.1.tgz#b1f3e04e8a94a715d5a7bcbc8339c51e6d74ca51"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
......@@ -173,8 +173,8 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.0.17",
"vscode-languageclient": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2",
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-nls": "^3.2.2"
},
"devDependencies": {
......
......@@ -8,11 +8,11 @@
"node": "*"
},
"dependencies": {
"vscode-css-languageservice": "^3.0.9-next.10",
"vscode-html-languageservice": "^2.1.3-next.3",
"vscode-languageserver": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2",
"vscode-languageserver-types": "^3.6.1",
"vscode-css-languageservice": "^3.0.9-next.15",
"vscode-html-languageservice": "^2.1.3-next.4",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-languageserver-types": "^3.7.2",
"vscode-nls": "^3.2.2",
"vscode-uri": "^1.0.3"
},
......
......@@ -48,7 +48,7 @@ documents.listen(connection);
let workspaceFolders: WorkspaceFolder[] = [];
var languageModes: LanguageModes;
let languageModes: LanguageModes;
let clientSnippetSupport = false;
let clientDynamicRegisterSupport = false;
......@@ -56,7 +56,7 @@ let scopedSettingsSupport = false;
let workspaceFoldersSupport = false;
let foldingRangeLimit = Number.MAX_VALUE;
var globalSettings: Settings = {};
let globalSettings: Settings = {};
let documentSettings: { [key: string]: Thenable<Settings> } = {};
// remove document settings on close
documents.onDidClose(e => {
......@@ -67,8 +67,8 @@ function getDocumentSettings(textDocument: TextDocument, needsDocumentSettings:
if (scopedSettingsSupport && needsDocumentSettings()) {
let promise = documentSettings[textDocument.uri];
if (!promise) {
let scopeUri = textDocument.uri;
let configRequestParam: ConfigurationParams = { items: [{ scopeUri, section: 'css' }, { scopeUri, section: 'html' }, { scopeUri, section: 'javascript' }] };
const scopeUri = textDocument.uri;
const configRequestParam: ConfigurationParams = { items: [{ scopeUri, section: 'css' }, { scopeUri, section: 'html' }, { scopeUri, section: 'javascript' }] };
promise = connection.sendRequest(ConfigurationRequest.type, configRequestParam).then(s => ({ css: s[0], html: s[1], javascript: s[2] }));
documentSettings[textDocument.uri] = promise;
}
......@@ -80,7 +80,7 @@ function getDocumentSettings(textDocument: TextDocument, needsDocumentSettings:
// After the server has started the client sends an initialize request. The server receives
// in the passed params the rootPath of the workspace plus the client capabilities
connection.onInitialize((params: InitializeParams): InitializeResult => {
let initializationOptions = params.initializationOptions;
const initializationOptions = params.initializationOptions;
workspaceFolders = (<any>params).workspaceFolders;
if (!Array.isArray(workspaceFolders)) {
......@@ -103,7 +103,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
});
function getClientCapability<T>(name: string, def: T) {
let keys = name.split('.');
const keys = name.split('.');
let c: any = params.capabilities;
for (let i = 0; c && i < keys.length; i++) {
if (!c.hasOwnProperty(keys[i])) {
......@@ -119,7 +119,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
scopedSettingsSupport = getClientCapability('workspace.configuration', false);
workspaceFoldersSupport = getClientCapability('workspace.workspaceFolders', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
let capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['.', ':', '<', '"', '=', '/'] } : undefined,
......@@ -142,11 +142,11 @@ connection.onInitialized((p) => {
connection.client.register(DidChangeWorkspaceFoldersNotification.type);
connection.onNotification(DidChangeWorkspaceFoldersNotification.type, e => {
let toAdd = e.event.added;
let toRemove = e.event.removed;
let updatedFolders = [];
const toAdd = e.event.added;
const toRemove = e.event.removed;
const updatedFolders = [];
if (workspaceFolders) {
for (let folder of workspaceFolders) {
for (const folder of workspaceFolders) {
if (!toRemove.some(r => r.uri === folder.uri) && !toAdd.some(r => r.uri === folder.uri)) {
updatedFolders.push(folder);
}
......@@ -168,10 +168,10 @@ connection.onDidChangeConfiguration((change) => {
// dynamically enable & disable the formatter
if (clientDynamicRegisterSupport) {
let enableFormatter = globalSettings && globalSettings.html && globalSettings.html.format && globalSettings.html.format.enable;
const enableFormatter = globalSettings && globalSettings.html && globalSettings.html.format && globalSettings.html.format.enable;
if (enableFormatter) {
if (!formatterRegistration) {
let documentSelector: DocumentSelector = [{ language: 'html' }, { language: 'handlebars' }]; // don't register razor, the formatter does more harm than good
const documentSelector: DocumentSelector = [{ language: 'html' }, { language: 'handlebars' }]; // don't register razor, the formatter does more harm than good
formatterRegistration = connection.client.register(DocumentRangeFormattingRequest.type, { documentSelector });
}
} else if (formatterRegistration) {
......@@ -197,7 +197,7 @@ documents.onDidClose(event => {
});
function cleanPendingValidation(textDocument: TextDocument): void {
let request = pendingValidationRequests[textDocument.uri];
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
delete pendingValidationRequests[textDocument.uri];
......@@ -213,7 +213,7 @@ function triggerValidation(textDocument: TextDocument): void {
}
function isValidationEnabled(languageId: string, settings: Settings = globalSettings) {
let validationSettings = settings && settings.html && settings.html.validate;
const validationSettings = settings && settings.html && settings.html.validate;
if (validationSettings) {
return languageId === 'css' && validationSettings.styles !== false || languageId === 'javascript' && validationSettings.scripts !== false;
}
......@@ -222,19 +222,19 @@ function isValidationEnabled(languageId: string, settings: Settings = globalSett
async function validateTextDocument(textDocument: TextDocument) {
try {
let version = textDocument.version;
let diagnostics: Diagnostic[] = [];
const version = textDocument.version;
const diagnostics: Diagnostic[] = [];
if (textDocument.languageId === 'html') {
let modes = languageModes.getAllModesInDocument(textDocument);
let settings = await getDocumentSettings(textDocument, () => modes.some(m => !!m.doValidation));
textDocument = documents.get(textDocument.uri);
if (textDocument && textDocument.version === version) { // check no new version has come in after in after the async op
const modes = languageModes.getAllModesInDocument(textDocument);
const settings = await getDocumentSettings(textDocument, () => modes.some(m => !!m.doValidation));
const latestTextDocument = documents.get(textDocument.uri);
if (latestTextDocument && latestTextDocument.version === version) { // check no new version has come in after in after the async op
modes.forEach(mode => {
if (mode.doValidation && isValidationEnabled(mode.getId(), settings)) {
pushAll(diagnostics, mode.doValidation(textDocument, settings));
pushAll(diagnostics, mode.doValidation(latestTextDocument, settings));
}
});
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
connection.sendDiagnostics({ uri: latestTextDocument.uri, diagnostics });
}
}
} catch (e) {
......@@ -245,6 +245,9 @@ async function validateTextDocument(textDocument: TextDocument) {
connection.onCompletion(async (textDocumentPosition, token) => {
return runSafeAsync(async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (!document) {
return null;
}
const mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
if (!mode || !mode.doComplete) {
return { isIncomplete: true, items: [] };
......@@ -260,8 +263,8 @@ connection.onCompletion(async (textDocumentPosition, token) => {
connection.telemetry.logEvent({ key: 'html.embbedded.complete', value: { languageId: mode.getId() } });
}
let settings = await getDocumentSettings(document, () => doComplete.length > 2);
let result = doComplete(document, textDocumentPosition.position, settings);
const settings = await getDocumentSettings(document, () => doComplete.length > 2);
const result = doComplete(document, textDocumentPosition.position, settings);
return result;
}, null, `Error while computing completions for ${textDocumentPosition.textDocument.uri}`, token);
......@@ -269,10 +272,10 @@ connection.onCompletion(async (textDocumentPosition, token) => {
connection.onCompletionResolve((item, token) => {
return runSafe(() => {
let data = item.data;
const data = item.data;
if (data && data.languageId && data.uri) {
let mode = languageModes.getMode(data.languageId);
let document = documents.get(data.uri);
const mode = languageModes.getMode(data.languageId);
const document = documents.get(data.uri);
if (mode && mode.doResolve && document) {
return mode.doResolve(document, item);
}
......@@ -283,10 +286,12 @@ connection.onCompletionResolve((item, token) => {
connection.onHover((textDocumentPosition, token) => {
return runSafe(() => {
let document = documents.get(textDocumentPosition.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
if (mode && mode.doHover) {
return mode.doHover(document, textDocumentPosition.position);
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
if (mode && mode.doHover) {
return mode.doHover(document, textDocumentPosition.position);
}
}
return null;
}, null, `Error while computing hover for ${textDocumentPosition.textDocument.uri}`, token);
......@@ -294,10 +299,12 @@ connection.onHover((textDocumentPosition, token) => {
connection.onDocumentHighlight((documentHighlightParams, token) => {
return runSafe(() => {
let document = documents.get(documentHighlightParams.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, documentHighlightParams.position);
if (mode && mode.findDocumentHighlight) {
return mode.findDocumentHighlight(document, documentHighlightParams.position);
const document = documents.get(documentHighlightParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, documentHighlightParams.position);
if (mode && mode.findDocumentHighlight) {
return mode.findDocumentHighlight(document, documentHighlightParams.position);
}
}
return [];
}, [], `Error while computing document highlights for ${documentHighlightParams.textDocument.uri}`, token);
......@@ -305,10 +312,12 @@ connection.onDocumentHighlight((documentHighlightParams, token) => {
connection.onDefinition((definitionParams, token) => {
return runSafe(() => {
let document = documents.get(definitionParams.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, definitionParams.position);
if (mode && mode.findDefinition) {
return mode.findDefinition(document, definitionParams.position);
const document = documents.get(definitionParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, definitionParams.position);
if (mode && mode.findDefinition) {
return mode.findDefinition(document, definitionParams.position);
}
}
return [];
}, null, `Error while computing definitions for ${definitionParams.textDocument.uri}`, token);
......@@ -316,10 +325,12 @@ connection.onDefinition((definitionParams, token) => {
connection.onReferences((referenceParams, token) => {
return runSafe(() => {
let document = documents.get(referenceParams.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, referenceParams.position);
if (mode && mode.findReferences) {
return mode.findReferences(document, referenceParams.position);
const document = documents.get(referenceParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, referenceParams.position);
if (mode && mode.findReferences) {
return mode.findReferences(document, referenceParams.position);
}
}
return [];
}, [], `Error while computing references for ${referenceParams.textDocument.uri}`, token);
......@@ -327,10 +338,12 @@ connection.onReferences((referenceParams, token) => {
connection.onSignatureHelp((signatureHelpParms, token) => {
return runSafe(() => {
let document = documents.get(signatureHelpParms.textDocument.uri);
let mode = languageModes.getModeAtPosition(document, signatureHelpParms.position);
if (mode && mode.doSignatureHelp) {
return mode.doSignatureHelp(document, signatureHelpParms.position);
const document = documents.get(signatureHelpParms.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, signatureHelpParms.position);
if (mode && mode.doSignatureHelp) {
return mode.doSignatureHelp(document, signatureHelpParms.position);
}
}
return null;
}, null, `Error while computing signature help for ${signatureHelpParms.textDocument.uri}`, token);
......@@ -338,24 +351,27 @@ connection.onSignatureHelp((signatureHelpParms, token) => {
connection.onDocumentRangeFormatting(async (formatParams, token) => {
return runSafeAsync(async () => {
let document = documents.get(formatParams.textDocument.uri);
let settings = await getDocumentSettings(document, () => true);
if (!settings) {
settings = globalSettings;
}
let unformattedTags: string = settings && settings.html && settings.html.format && settings.html.format.unformatted || '';
let enabledModes = { css: !unformattedTags.match(/\bstyle\b/), javascript: !unformattedTags.match(/\bscript\b/) };
const document = documents.get(formatParams.textDocument.uri);
if (document) {
let settings = await getDocumentSettings(document, () => true);
if (!settings) {
settings = globalSettings;
}
const unformattedTags: string = settings && settings.html && settings.html.format && settings.html.format.unformatted || '';
const enabledModes = { css: !unformattedTags.match(/\bstyle\b/), javascript: !unformattedTags.match(/\bscript\b/) };
return format(languageModes, document, formatParams.range, formatParams.options, settings, enabledModes);
return format(languageModes, document, formatParams.range, formatParams.options, settings, enabledModes);
}
return [];
}, [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentLinks((documentLinkParam, token) => {
return runSafe(() => {
let document = documents.get(documentLinkParam.textDocument.uri);
let links: DocumentLink[] = [];
const document = documents.get(documentLinkParam.textDocument.uri);
const links: DocumentLink[] = [];
if (document) {
let documentContext = getDocumentContext(document.uri, workspaceFolders);
const documentContext = getDocumentContext(document.uri, workspaceFolders);
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentLinks) {
pushAll(links, m.findDocumentLinks(document, documentContext));
......@@ -368,21 +384,23 @@ connection.onDocumentLinks((documentLinkParam, token) => {
connection.onDocumentSymbol((documentSymbolParms, token) => {
return runSafe(() => {
let document = documents.get(documentSymbolParms.textDocument.uri);
let symbols: SymbolInformation[] = [];
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentSymbols) {
pushAll(symbols, m.findDocumentSymbols(document));
}
});
const document = documents.get(documentSymbolParms.textDocument.uri);
const symbols: SymbolInformation[] = [];
if (document) {
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentSymbols) {
pushAll(symbols, m.findDocumentSymbols(document));
}
});
}
return symbols;
}, [], `Error while computing document symbols for ${documentSymbolParms.textDocument.uri}`, token);
});
connection.onRequest(DocumentColorRequest.type, (params, token) => {
return runSafe(() => {
let infos: ColorInformation[] = [];
let document = documents.get(params.textDocument.uri);
const infos: ColorInformation[] = [];
const document = documents.get(params.textDocument.uri);
if (document) {
languageModes.getAllModesInDocument(document).forEach(m => {
if (m.findDocumentColors) {
......@@ -396,9 +414,9 @@ connection.onRequest(DocumentColorRequest.type, (params, token) => {
connection.onRequest(ColorPresentationRequest.type, (params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
let mode = languageModes.getModeAtPosition(document, params.range.start);
const mode = languageModes.getModeAtPosition(document, params.range.start);
if (mode && mode.getColorPresentations) {
return mode.getColorPresentations(document, params.color, params.range);
}
......@@ -409,11 +427,11 @@ connection.onRequest(ColorPresentationRequest.type, (params, token) => {
connection.onRequest(TagCloseRequest.type, (params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
let pos = params.position;
const pos = params.position;
if (pos.character > 0) {
let mode = languageModes.getModeAtPosition(document, Position.create(pos.line, pos.character - 1));
const mode = languageModes.getModeAtPosition(document, Position.create(pos.line, pos.character - 1));
if (mode && mode.doAutoClose) {
return mode.doAutoClose(document, pos);
}
......@@ -425,7 +443,7 @@ connection.onRequest(TagCloseRequest.type, (params, token) => {
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
return getFoldingRanges(languageModes, document, foldingRangeLimit, token);
}
......
......@@ -10,54 +10,50 @@
version "7.0.43"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c"
vscode-css-languageservice@^3.0.9-next.10:
version "3.0.9-next.10"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.10.tgz#be73d571221176b43d2c398a4a27f7d38206952d"
vscode-css-languageservice@^3.0.9-next.15:
version "3.0.9-next.15"
resolved "https://registry.yarnpkg.com/vscode-css-languageservice/-/vscode-css-languageservice-3.0.9-next.15.tgz#67a91ed2cc7cf6ea46d45c2e9e9332c74df06ec5"
dependencies:
vscode-languageserver-types "^3.6.1"
vscode-nls "^3.2.1"
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-html-languageservice@^2.1.3-next.3:
version "2.1.3-next.3"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.1.3-next.3.tgz#20c4a0ae673815b598a7e132b5ef03a6920fa7af"
vscode-html-languageservice@^2.1.3-next.4:
version "2.1.3-next.4"
resolved "https://registry.yarnpkg.com/vscode-html-languageservice/-/vscode-html-languageservice-2.1.3-next.4.tgz#b6785d9a1d212c163e6e7a4b2bfc728e413241ee"
dependencies:
vscode-languageserver-types "^3.6.1"
vscode-nls "^3.2.1"
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-uri "^1.0.3"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0, vscode-languageserver-types@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz#4bc06a48dff653495f12f94b8b1e228988a1748d"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.0.0.tgz#8b792f0d6d10acfe363d02371ed4ce53d08af88a"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-nls@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.1.tgz#b1f3e04e8a94a715d5a7bcbc8339c51e6d74ca51"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
......
......@@ -34,33 +34,33 @@ vscode-extension-telemetry@0.0.17:
dependencies:
applicationinsights "1.0.1"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.0.0.tgz#635f5bfbcfa1385dae489b394857f1db8b459a7d"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0:
version "3.6.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz#4bc06a48dff653495f12f94b8b1e228988a1748d"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-nls@^3.2.2:
version "3.2.2"
......
......@@ -101,8 +101,8 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.0.17",
"vscode-languageclient": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2",
"vscode-languageclient": "^4.1.4",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-nls": "^3.2.2"
},
"devDependencies": {
......
......@@ -13,9 +13,9 @@
"dependencies": {
"jsonc-parser": "^2.0.0-next.1",
"request-light": "^0.2.2",
"vscode-json-languageservice": "^3.1.2-next.2",
"vscode-languageserver": "^4.0.0",
"vscode-languageserver-protocol-foldingprovider": "^2.0.0-next.2",
"vscode-json-languageservice": "^3.1.2-next.3",
"vscode-languageserver": "^4.1.3",
"vscode-languageserver-protocol-foldingprovider": "^2.0.1",
"vscode-nls": "^3.2.2",
"vscode-uri": "^1.0.3"
},
......
......@@ -38,7 +38,7 @@ namespace SchemaContentChangeNotification {
}
// Create a connection for the server
let connection: IConnection = createConnection();
const connection: IConnection = createConnection();
process.on('unhandledRejection', (e: any) => {
console.error(formatError(`Unhandled exception`, e));
......@@ -53,7 +53,7 @@ console.error = connection.console.error.bind(connection.console);
// Create a simple text document manager. The text document manager
// supports full document sync only
let documents: TextDocuments = new TextDocuments();
const documents: TextDocuments = new TextDocuments();
// Make the text document manager listen on the connection
// for open, change and close text document events
documents.listen(connection);
......@@ -67,7 +67,7 @@ let foldingRangeLimit = Number.MAX_VALUE;
connection.onInitialize((params: InitializeParams): InitializeResult => {
function getClientCapability<T>(name: string, def: T) {
let keys = name.split('.');
const keys = name.split('.');
let c: any = params.capabilities;
for (let i = 0; c && i < keys.length; i++) {
if (!c.hasOwnProperty(keys[i])) {
......@@ -81,7 +81,7 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
clientSnippetSupport = getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
clientDynamicRegisterSupport = getClientCapability('workspace.symbol.dynamicRegistration', false);
foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
let capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
const capabilities: ServerCapabilities & FoldingRangeServerCapabilities = {
// Tell the client that the server works in FULL text document sync mode
textDocumentSync: documents.syncKind,
completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['"', ':'] } : void 0,
......@@ -95,15 +95,15 @@ connection.onInitialize((params: InitializeParams): InitializeResult => {
return { capabilities };
});
let workspaceContext = {
const workspaceContext = {
resolveRelativePath: (relativePath: string, resource: string) => {
return URL.resolve(resource, relativePath);
}
};
let schemaRequestService = (uri: string): Thenable<string> => {
const schemaRequestService = (uri: string): Thenable<string> => {
if (startsWith(uri, 'file://')) {
let fsPath = URI.parse(uri).fsPath;
const fsPath = URI.parse(uri).fsPath;
return new Promise<string>((c, e) => {
fs.readFile(fsPath, 'UTF-8', (err, result) => {
err ? e('') : c(result.toString());
......@@ -129,7 +129,7 @@ let schemaRequestService = (uri: string): Thenable<string> => {
}
});
}
let headers = { 'Accept-Encoding': 'gzip, deflate' };
const headers = { 'Accept-Encoding': 'gzip, deflate' };
return xhr({ url: uri, followRedirects: 5, headers }).then(response => {
return response.responseText;
}, (error: XHRResponse) => {
......@@ -138,7 +138,7 @@ let schemaRequestService = (uri: string): Thenable<string> => {
};
// create the JSON language service
let languageService = getLanguageService({
const languageService = getLanguageService({
schemaRequestService,
workspaceContext,
contributions: []
......@@ -176,7 +176,7 @@ connection.onDidChangeConfiguration((change) => {
// dynamically enable & disable the formatter
if (clientDynamicRegisterSupport) {
let enableFormatter = settings && settings.json && settings.json.format && settings.json.format.enable;
const enableFormatter = settings && settings.json && settings.json.format && settings.json.format.enable;
if (enableFormatter) {
if (!formatterRegistration) {
formatterRegistration = connection.client.register(DocumentRangeFormattingRequest.type, { documentSelector: [{ language: 'json' }, { language: 'jsonc' }] });
......@@ -200,14 +200,14 @@ connection.onNotification(SchemaContentChangeNotification.type, uri => {
});
function updateConfiguration() {
let languageSettings = {
const languageSettings = {
validate: true,
allowComments: true,
schemas: new Array<SchemaConfiguration>()
};
if (schemaAssociations) {
for (var pattern in schemaAssociations) {
let association = schemaAssociations[pattern];
const association = schemaAssociations[pattern];
if (Array.isArray(association)) {
association.forEach(uri => {
languageSettings.schemas.push({ uri, fileMatch: [pattern] });
......@@ -244,11 +244,11 @@ documents.onDidClose(event => {
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
});
let pendingValidationRequests: { [uri: string]: NodeJS.Timer; } = {};
const pendingValidationRequests: { [uri: string]: NodeJS.Timer; } = {};
const validationDelayMs = 500;
function cleanPendingValidation(textDocument: TextDocument): void {
let request = pendingValidationRequests[textDocument.uri];
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
delete pendingValidationRequests[textDocument.uri];
......@@ -269,13 +269,13 @@ function validateTextDocument(textDocument: TextDocument): void {
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: [] });
return;
}
let jsonDocument = getJSONDocument(textDocument);
let version = textDocument.version;
const jsonDocument = getJSONDocument(textDocument);
const version = textDocument.version;
let documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' };
const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' };
languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
setTimeout(() => {
let currDocument = documents.get(textDocument.uri);
const currDocument = documents.get(textDocument.uri);
if (currDocument && currDocument.version === version) {
// Send the computed diagnostics to VSCode.
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
......@@ -299,7 +299,7 @@ connection.onDidChangeWatchedFiles((change) => {
}
});
let jsonDocuments = getLanguageModelCache<JSONDocument>(10, 60, document => languageService.parseJSONDocument(document));
const jsonDocuments = getLanguageModelCache<JSONDocument>(10, 60, document => languageService.parseJSONDocument(document));
documents.onDidClose(e => {
jsonDocuments.onDocumentRemoved(e.document);
});
......@@ -312,10 +312,13 @@ function getJSONDocument(document: TextDocument): JSONDocument {
}
connection.onCompletion((textDocumentPosition, token) => {
return runSafeAsync(() => {
let document = documents.get(textDocumentPosition.textDocument.uri);
let jsonDocument = getJSONDocument(document);
return languageService.doComplete(document, textDocumentPosition.position, jsonDocument);
return runSafeAsync(async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
return languageService.doComplete(document, textDocumentPosition.position, jsonDocument);
}
return null;
}, null, `Error while computing completions for ${textDocumentPosition.textDocument.uri}`, token);
});
......@@ -326,44 +329,53 @@ connection.onCompletionResolve((completionItem, token) => {
});
connection.onHover((textDocumentPositionParams, token) => {
return runSafeAsync(() => {
let document = documents.get(textDocumentPositionParams.textDocument.uri);
let jsonDocument = getJSONDocument(document);
return languageService.doHover(document, textDocumentPositionParams.position, jsonDocument);
return runSafeAsync(async () => {
const document = documents.get(textDocumentPositionParams.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
return languageService.doHover(document, textDocumentPositionParams.position, jsonDocument);
}
return null;
}, null, `Error while computing hover for ${textDocumentPositionParams.textDocument.uri}`, token);
});
connection.onDocumentSymbol((documentSymbolParams, token) => {
return runSafe(() => {
let document = documents.get(documentSymbolParams.textDocument.uri);
let jsonDocument = getJSONDocument(document);
return languageService.findDocumentSymbols(document, jsonDocument);
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
return languageService.findDocumentSymbols(document, jsonDocument);
}
return [];
}, [], `Error while computing document symbols for ${documentSymbolParams.textDocument.uri}`, token);
});
connection.onDocumentRangeFormatting((formatParams, token) => {
return runSafe(() => {
let document = documents.get(formatParams.textDocument.uri);
return languageService.format(document, formatParams.range, formatParams.options);
const document = documents.get(formatParams.textDocument.uri);
if (document) {
return languageService.format(document, formatParams.range, formatParams.options);
}
return [];
}, [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentColor((params, token) => {
return runSafeAsync(() => {
let document = documents.get(params.textDocument.uri);
return runSafeAsync(async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
let jsonDocument = getJSONDocument(document);
const jsonDocument = getJSONDocument(document);
return languageService.findDocumentColors(document, jsonDocument);
}
return Promise.resolve([]);
return [];
}, [], `Error while computing document colors for ${params.textDocument.uri}`, token);
});
connection.onColorPresentation((params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
let jsonDocument = getJSONDocument(document);
const jsonDocument = getJSONDocument(document);
return languageService.getColorPresentations(document, jsonDocument, params.color, params.range);
}
return [];
......@@ -372,7 +384,7 @@ connection.onColorPresentation((params, token) => {
connection.onRequest(FoldingRangeRequest.type, (params, token) => {
return runSafe(() => {
let document = documents.get(params.textDocument.uri);
const document = documents.get(params.textDocument.uri);
if (document) {
return languageService.getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
}
......
......@@ -72,56 +72,48 @@ request-light@^0.2.2:
https-proxy-agent "2.1.1"
vscode-nls "^2.0.2"
vscode-json-languageservice@^3.1.2-next.2:
version "3.1.2-next.2"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.1.2-next.2.tgz#da5346e5c22edbce739f29c110eb41732d41dc2d"
vscode-json-languageservice@^3.1.2-next.3:
version "3.1.2-next.3"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.1.2-next.3.tgz#cc0902148f898b413987fb1b4c4a9e7fc1a79c78"
dependencies:
jsonc-parser "^2.0.0"
vscode-languageserver-types "^3.6.1"
vscode-nls "^3.2.1"
vscode-languageserver-types "^3.7.2"
vscode-nls "^3.2.2"
vscode-uri "^1.0.3"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.0.tgz#0bba63b0fa82a714394a4478f55a596ee4ed7d0a"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-languageserver-types@^3.6.1:
version "3.6.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.1.tgz#4bc06a48dff653495f12f94b8b1e228988a1748d"
vscode-languageserver@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.0.0.tgz#8b792f0d6d10acfe363d02371ed4ce53d08af88a"
vscode-languageserver@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/vscode-languageserver/-/vscode-languageserver-4.1.3.tgz#937d37c955b6b9c2409388413cd6f54d1eb9fe7d"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-uri "^1.0.1"
vscode-nls@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-2.0.2.tgz#808522380844b8ad153499af5c3b03921aea02da"
vscode-nls@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.1.tgz#b1f3e04e8a94a715d5a7bcbc8339c51e6d74ca51"
vscode-nls@^3.2.2:
version "3.2.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-3.2.2.tgz#3817eca5b985c2393de325197cf4e15eb2aa5350"
......
......@@ -34,33 +34,33 @@ vscode-extension-telemetry@0.0.17:
dependencies:
applicationinsights "1.0.1"
vscode-jsonrpc@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.0.tgz#848d56995d5168950d84feb5d9c237ae5c6a02d4"
vscode-jsonrpc@^3.6.2:
version "3.6.2"
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-3.6.2.tgz#3b5eef691159a15556ecc500e9a8a0dd143470c8"
vscode-languageclient@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.0.0.tgz#635f5bfbcfa1385dae489b394857f1db8b459a7d"
vscode-languageclient@^4.1.4:
version "4.1.4"
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-4.1.4.tgz#fff1a6bca4714835dca7fce35bc4ce81442fdf2c"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-protocol-foldingprovider@^2.0.0-next.2:
version "2.0.0-next.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.0-next.2.tgz#fbb9cfdf5b8c4ac451826ba6312f1f88379f35b0"
vscode-languageserver-protocol-foldingprovider@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol-foldingprovider/-/vscode-languageserver-protocol-foldingprovider-2.0.1.tgz#051d0d9e58d1b79dc4681acd48f21797f5515bfd"
dependencies:
vscode-languageserver-protocol "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-languageserver-protocol "^3.7.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-protocol@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.6.0.tgz#579642cdcccf74b0cd771c33daa3239acb40d040"
vscode-languageserver-protocol@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.7.2.tgz#df58621c032139010888b6a9ddc969423f9ba9d6"
dependencies:
vscode-jsonrpc "^3.6.0"
vscode-languageserver-types "^3.6.0"
vscode-jsonrpc "^3.6.2"
vscode-languageserver-types "^3.7.2"
vscode-languageserver-types@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.6.0.tgz#0bba63b0fa82a714394a4478f55a596ee4ed7d0a"
vscode-languageserver-types@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.7.2.tgz#aad8846f8e3e27962648554de5a8417e358f34eb"
vscode-nls@^3.2.2:
version "3.2.2"
......
......@@ -53,7 +53,11 @@
},
{
"command": "npm.debugScript",
"title": "%command.debug%"
"title": "%command.debug%",
"icon": {
"light": "resources/light/debug.svg",
"dark": "resources/dark/debug.svg"
}
},
{
"command": "npm.openScript",
......@@ -93,11 +97,20 @@
"group": "navigation@2"
},
{
"command": "npm.runScript",
"command": "npm.runScript",
"when": "view == npm && viewItem == script",
"group": "inline"
},
{
"command": "npm.runScript",
"when": "view == npm && viewItem == debugScript",
"group": "inline"
},
{
"command": "npm.debugScript",
"when": "view == npm && viewItem == debugScript",
"group": "inline"
}, {
"command": "npm.debugScript",
"when": "view == npm && viewItem == script",
"group": "navigation@3"
......
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="12" height="12" style="fill:#C5C5C5;fill-opacity:1;" viewBox="0 0 512 512">
<title></title>
<g id="icomoon-ignore">
</g>
<path d="M512 288v-32h-96.645c-2.931-36.343-15.893-69.513-35.835-96.125h80.972l35.030-140.12-31.045-7.761-28.97 115.88h-87.34c-0.446-0.347-0.898-0.687-1.349-1.028 3.355-9.751 5.181-20.211 5.181-31.097 0.001-52.88-42.979-95.749-95.999-95.749s-96 42.869-96 95.75c0 10.886 1.825 21.346 5.181 31.097-0.45 0.342-0.902 0.681-1.349 1.028h-87.34l-28.97-115.88-31.045 7.761 35.030 140.12h80.972c-19.942 26.611-32.903 59.781-35.834 96.124h-96.645v32h96.685c1.901 22.832 7.754 44.406 16.819 63.875h-61.996l-35.030 140.119 31.045 7.762 28.97-115.881h56.177c29.346 39.016 73.698 63.875 123.33 63.875s93.983-24.859 123.331-63.875h56.177l28.97 115.881 31.045-7.762-35.030-140.119h-61.996c9.065-19.469 14.918-41.043 16.818-63.875h96.685z"></path>
</svg>
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="12" height="12" style="fill:#464D46;fill-opacity:1;" viewBox="0 0 512 512">
<title></title>
<g id="icomoon-ignore">
</g>
<path d="M512 288v-32h-96.645c-2.931-36.343-15.893-69.513-35.835-96.125h80.972l35.030-140.12-31.045-7.761-28.97 115.88h-87.34c-0.446-0.347-0.898-0.687-1.349-1.028 3.355-9.751 5.181-20.211 5.181-31.097 0.001-52.88-42.979-95.749-95.999-95.749s-96 42.869-96 95.75c0 10.886 1.825 21.346 5.181 31.097-0.45 0.342-0.902 0.681-1.349 1.028h-87.34l-28.97-115.88-31.045 7.761 35.030 140.12h80.972c-19.942 26.611-32.903 59.781-35.834 96.124h-96.645v32h96.685c1.901 22.832 7.754 44.406 16.819 63.875h-61.996l-35.030 140.119 31.045 7.762 28.97-115.881h56.177c29.346 39.016 73.698 63.875 123.33 63.875s93.983-24.859 123.331-63.875h56.177l28.97 115.881 31.045-7.762-35.030-140.119h-61.996c9.065-19.469 14.918-41.043 16.818-63.875h96.685z"></path>
</svg>
......@@ -72,6 +72,9 @@ class NpmScript extends TreeItem {
constructor(context: ExtensionContext, packageJson: PackageJSON, task: Task) {
super(task.name, TreeItemCollapsibleState.None);
this.contextValue = 'script';
if (task.group && task.group === TaskGroup.Rebuild) {
this.contextValue = 'debugScript';
}
this.package = packageJson;
this.task = task;
this.command = {
......@@ -141,7 +144,7 @@ export class NpmScriptsTreeDataProvider implements TreeDataProvider<TreeItem> {
workspace.executeTask(script.task);
}
private async extractDebugArg(scripts: any, task: Task): Promise<[string, number] | undefined> {
private extractDebugArg(scripts: any, task: Task): [string, number] | undefined {
let script: string = scripts[task.name];
let match = script.match(/--(inspect|debug)(-brk)?(=(\d*))?/);
......
......@@ -157,6 +157,11 @@ function isExcluded(folder: WorkspaceFolder, packageJsonUri: Uri) {
return false;
}
function isDebugScript(script: string): boolean {
let match = script.match(/--(inspect|debug)(-brk)?(=(\d*))?/);
return match !== null;
}
async function provideNpmScriptsForFolder(packageJsonUri: Uri): Promise<Task[]> {
let emptyTasks: Task[] = [];
......@@ -183,6 +188,9 @@ async function provideNpmScriptsForFolder(packageJsonUri: Uri): Promise<Task[]>
if (prePostScripts.has(each)) {
task.group = TaskGroup.Clean; // hack: use Clean group to tag pre/post scripts
}
if (isDebugScript(scripts![each])) {
task.group = TaskGroup.Rebuild; // hack: use Rebuild group to tag debug scripts
}
result.push(task);
});
// always add npm install (without a problem matcher)
......
......@@ -11,6 +11,7 @@ import * as vscode from 'vscode';
import { rgPath } from 'vscode-ripgrep';
import { normalizeNFC, normalizeNFD } from './normalization';
import { rgErrorMsgForDisplay } from './ripgrepTextSearch';
import { anchorGlob } from './ripgrepHelpers';
const isMac = process.platform === 'darwin';
......@@ -162,7 +163,7 @@ function getRgArgs(options: vscode.FileSearchOptions): string[] {
const args = ['--files', '--hidden', '--case-sensitive'];
options.includes.forEach(globArg => {
const inclusion = anchor(globArg);
const inclusion = anchorGlob(globArg);
args.push('-g', inclusion);
if (isMac) {
const normalized = normalizeNFD(inclusion);
......@@ -173,7 +174,7 @@ function getRgArgs(options: vscode.FileSearchOptions): string[] {
});
options.excludes.forEach(globArg => {
const exclusion = `!${anchor(globArg)}`;
const exclusion = `!${anchorGlob(globArg)}`;
args.push('-g', exclusion);
if (isMac) {
const normalized = normalizeNFD(exclusion);
......@@ -202,7 +203,3 @@ function getRgArgs(options: vscode.FileSearchOptions): string[] {
return args;
}
function anchor(glob: string) {
return glob.startsWith('**') || glob.startsWith('/') ? glob : `/${glob}`;
}
......@@ -16,8 +16,6 @@ export function fixDriveC(_path: string): string {
_path;
}
function trimTrailingSlash(str: string): string {
return str
.replace(/\/$/, '')
.replace(/\\$/, '');
export function anchorGlob(glob: string): string {
return glob.startsWith('**') || glob.startsWith('/') ? glob : `/${glob}`;
}
......@@ -14,6 +14,7 @@ import { StringDecoder, NodeStringDecoder } from 'string_decoder';
import * as cp from 'child_process';
import { rgPath } from 'vscode-ripgrep';
import { start } from 'repl';
import { anchorGlob } from './ripgrepHelpers';
// If vscode-ripgrep is in an .asar file, then the binary is unpacked.
const rgDiskPath = rgPath.replace(/\bnode_modules\.asar\b/, 'node_modules.asar.unpacked');
......@@ -314,11 +315,12 @@ function getRgArgs(query: vscode.TextSearchQuery, options: vscode.TextSearchOpti
const args = ['--hidden', '--heading', '--line-number', '--color', 'ansi', '--colors', 'path:none', '--colors', 'line:none', '--colors', 'match:fg:red', '--colors', 'match:style:nobold'];
args.push(query.isCaseSensitive ? '--case-sensitive' : '--ignore-case');
// TODO@roblou
options.includes
.map(anchorGlob)
.forEach(globArg => args.push('-g', globArg));
options.excludes
.map(anchorGlob)
.forEach(rgGlob => args.push('-g', `!${rgGlob}`));
if (options.maxFileSize) {
......
......@@ -40,9 +40,12 @@ export class DiagnosticsManager {
private readonly _diagnostics = new Map<DiagnosticKind, DiagnosticSet>();
private readonly _currentDiagnostics: vscode.DiagnosticCollection;
private readonly _pendingUpdates: { [key: string]: any } = Object.create(null);
private _validate: boolean = true;
private _enableSuggestions: boolean = true;
private readonly updateDelay = 50;
constructor(
owner: string
) {
......@@ -55,6 +58,11 @@ export class DiagnosticsManager {
public dispose() {
this._currentDiagnostics.dispose();
for (const key of Object.keys(this._pendingUpdates)) {
clearTimeout(this._pendingUpdates[key]);
delete this._pendingUpdates[key];
}
}
public reInitialize(): void {
......@@ -93,10 +101,21 @@ export class DiagnosticsManager {
diagnostics: vscode.Diagnostic[]
): void {
const collection = this._diagnostics.get(kind);
if (collection) {
collection.set(file, diagnostics);
this.updateCurrentDiagnostics(file);
if (!collection) {
return;
}
collection.set(file, diagnostics);
if (diagnostics.length === 0) {
const existing = collection.get(file);
if (existing.length === 0) {
// No need to update
return;
}
}
this.scheduleDiagnosticsUpdate(file);
}
public configFileDiagnosticsReceived(file: vscode.Uri, diagnostics: vscode.Diagnostic[]): void {
......@@ -107,7 +126,23 @@ export class DiagnosticsManager {
this._currentDiagnostics.delete(resource);
}
public getDiagnostics(file: vscode.Uri): vscode.Diagnostic[] {
return this._currentDiagnostics.get(file) || [];
}
private scheduleDiagnosticsUpdate(file: vscode.Uri) {
const key = file.fsPath;
if (!this._pendingUpdates[key]) {
this._pendingUpdates[key] = setTimeout(() => this.updateCurrentDiagnostics(file), this.updateDelay);
}
}
private updateCurrentDiagnostics(file: vscode.Uri) {
if (this._pendingUpdates[file.fsPath]) {
clearTimeout(this._pendingUpdates[file.fsPath]);
delete this._pendingUpdates[file.fsPath];
}
if (!this._validate) {
return;
}
......@@ -127,8 +162,4 @@ export class DiagnosticsManager {
return this._diagnostics.get(DiagnosticKind.Suggestion)!.get(file);
}
public getDiagnostics(file: vscode.Uri): vscode.Diagnostic[] {
return this._currentDiagnostics.get(file) || [];
}
}
\ No newline at end of file
......@@ -5,10 +5,10 @@
'use strict';
import { TPromise, PPromise, TValueCallback, TProgressCallback, ProgressCallback } from 'vs/base/common/winjs.base';
import * as errors from 'vs/base/common/errors';
import * as paths from 'vs/base/common/paths';
import URI from 'vs/base/common/uri';
import { PPromise, ProgressCallback, TProgressCallback, TPromise, TValueCallback } from 'vs/base/common/winjs.base';
export class DeferredTPromise<T> extends TPromise<T> {
......@@ -82,3 +82,15 @@ export class DeferredPPromise<C, P> extends PPromise<C, P> {
export function toResource(this: any, path: string) {
return URI.file(paths.join('C:\\', Buffer.from(this.test.fullTitle()).toString('base64'), path));
}
export function suiteRepeat(n: number, description: string, callback: (this: any) => void): void {
for (let i = 0; i < n; i++) {
suite(`${description} (iteration ${i})`, callback);
}
}
export function testRepeat(n: number, description: string, callback: (this: any, done: MochaDone) => any): void {
for (let i = 0; i < n; i++) {
test(`${description} (iteration ${i})`, callback);
}
}
......@@ -5,7 +5,6 @@
.settings-editor {
padding: 11px 0px 0px 27px;
max-width: 800px;
margin: auto;
}
......@@ -90,71 +89,91 @@
margin-left: 2px;
}
.settings-editor > .settings-body .settings-list-container .settings-list-offset-helper {
opacity: 0;
position: absolute;
.settings-editor > .settings-body .settings-tree-container .monaco-tree-wrapper {
max-width: 800px;
margin: auto;
}
.settings-editor > .settings-body .settings-tree-container .monaco-scrollable-element .shadow.top-left-corner {
left: calc((100% - 800px)/2);
}
.settings-editor > .settings-body .settings-list-container .monaco-list::before {
.settings-editor > .settings-body .settings-tree-container .monaco-scrollable-element .shadow {
left: calc((100% - 794px)/2);
width: 800px;
}
.settings-editor > .settings-body .settings-tree-container .monaco-tree::before {
outline: none !important;
}
.settings-editor > .settings-body .settings-list-container {
.settings-editor > .settings-body .settings-tree-container {
flex: 1;
border-spacing: 0;
border-collapse: separate;
position: relative;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row {
.settings-editor > .settings-body > .settings-tree-container .setting-item {
cursor: default;
white-space: normal;
display: flex;
height: 100%;
min-height: 75px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.odd:not(.focused):not(.selected):not(:hover),
.settings-editor > .settings-body > .settings-list-container .monaco-list:not(:focus) .monaco-list-row.focused.odd:not(.selected):not(:hover),
.settings-editor > .settings-body > .settings-list-container .monaco-list:not(.focused) .monaco-list-row.focused.odd:not(.selected):not(:hover) {
background-color: rgba(130, 130, 130, 0.04);
.settings-editor > .settings-body > .settings-tree-container .monaco-tree-row .content::before {
content: ' ';
display: inline-block;
position: absolute;
width: 5px;
left: -9px;
top: 2px;
bottom: 10px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.setting-item {
padding: 3px;
.settings-editor > .settings-body > .settings-tree-container .monaco-tree .monaco-tree-row {
background-color: initial !important;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row > .setting-item-container {
display: flex;
height: 100%;
.settings-editor > .settings-body > .settings-tree-container .setting-item.odd:not(.focused):not(.selected):not(:hover),
.settings-editor > .settings-body > .settings-tree-container .monaco-tree:not(:focus) .setting-item.focused.odd:not(.selected):not(:hover),
.settings-editor > .settings-body > .settings-tree-container .monaco-tree:not(.focused) .setting-item.focused.odd:not(.selected):not(:hover) {
background-color: rgba(130, 130, 130, 0.04);
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row > .setting-item-container > .setting-item-left {
.settings-editor > .settings-body > .settings-tree-container .setting-item > .setting-item-left {
flex: 1;
padding-top: 3px;
padding-bottom: 12px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row > .setting-item-container > .setting-item-right {
.settings-editor > .settings-body > .settings-tree-container .setting-item > .setting-item-right {
min-width: 180px;
margin: 21px 10px;
margin: 21px 10px 0px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-title {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-title {
line-height: initial;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-title .setting-item-overrides {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-title .setting-item-overrides {
opacity: 0.5;
margin-left: 7px;
font-style: italic;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-label {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-label,
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-category {
font-weight: bold;
font-size: 14px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-category {
font-weight: bold;
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-category {
opacity: 0.7;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-key {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-key {
margin-left: 10px;
font-family: Monaco, Menlo, Consolas, "Droid Sans Mono", "Inconsolata", "Courier New", monospace, "Droid Sans Fallback";
font-size: 90%;
......@@ -162,60 +181,56 @@
display: none;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-description {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-description {
opacity: 0.7;
margin-top: 5px;
margin-top: 3px;
height: 36px;
overflow: hidden;
white-space: pre-wrap;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.is-expanded .setting-item-description,
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.setting-item-measure-helper .setting-item-description {
height: initial;
.settings-editor > .settings-body > .settings-tree-container .setting-measure-container.monaco-tree-row {
padding-left: 15px;
opacity: 0;
max-width: 800px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.is-expandable .setting-item-description {
cursor: pointer;
.settings-editor > .settings-body > .settings-tree-container .setting-item.is-expanded .setting-item-description,
.settings-editor > .settings-body > .settings-tree-container .setting-item.setting-measure-helper .setting-item-description {
height: initial;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.is-expandable:not(.is-expanded) .setting-item-description::after {
content: '…';
display: block;
height: 4px;
width: 8px;
position: absolute;
bottom: 16px;
right: 202px;
.settings-editor > .settings-body > .settings-tree-container .setting-item.is-expandable .setting-item-description {
cursor: pointer;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value {
display: flex;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .edit-in-settings-button,
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .edit-in-settings-button:hover,
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .edit-in-settings-button:active {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .edit-in-settings-button,
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .edit-in-settings-button:hover,
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .edit-in-settings-button:active {
margin: auto;
text-align: left;
text-decoration: underline;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .edit-in-settings-button + .setting-reset-button.monaco-button {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .edit-in-settings-button + .setting-reset-button.monaco-button {
display: none;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .monaco-select-box {
.settings-editor > .settings-body > .settings-tree-container .setting-item .monaco-select-box {
width: 100%;
font: inherit;
height: 26px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-value-checkbox {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-value-checkbox {
position: relative;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.is-configured .setting-value-checkbox::after {
.settings-editor > .settings-body > .settings-tree-container .setting-item.is-configured .setting-value-checkbox::after {
content: ' ';
display: block;
height: 3px;
......@@ -225,7 +240,7 @@
left: -3px;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .setting-reset-button.monaco-button {
.settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .setting-reset-button.monaco-button {
display: inline-block;
background: url("clean.svg") center center no-repeat;
width: 16px;
......@@ -235,23 +250,36 @@
visibility: hidden;
}
.vs-dark .settings-editor > .settings-body > .settings-list-container .monaco-list-row .setting-item-value > .setting-reset-button.monaco-button {
.settings-editor > .settings-body > .settings-tree-container .setting-item .expand-indicator {
visibility: hidden;
position: absolute;
bottom: -2px;
width: calc(100% - 190px);
text-align: center;
opacity: .5;
}
.settings-editor > .settings-body > .settings-tree-container .setting-item.is-expandable .expand-indicator {
visibility: visible;
}
.vs-dark .settings-editor > .settings-body > .settings-tree-container .setting-item .setting-item-value > .setting-reset-button.monaco-button {
background: url("clean-dark.svg") center center no-repeat;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.is-configured .setting-item-value > .setting-reset-button.monaco-button {
.settings-editor > .settings-body > .settings-tree-container .setting-item.is-configured .setting-item-value > .setting-reset-button.monaco-button {
visibility: visible;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.all-settings {
.settings-editor > .settings-body > .settings-tree-container .all-settings {
display: flex;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.all-settings .all-settings-button {
.settings-editor > .settings-body > .settings-tree-container .all-settings .all-settings-button {
margin: auto;
}
.settings-editor > .settings-body > .settings-list-container .monaco-list-row.all-settings .all-settings-button .monaco-button {
.settings-editor > .settings-body > .settings-tree-container .all-settings .all-settings-button .monaco-button {
padding-left: 10px;
padding-right: 10px;
}
......@@ -264,57 +292,17 @@
This is risky, consider a different approach
*/
.settings-editor .settings-list-container .monaco-list-row {
.settings-editor .settings-tree-container .setting-item {
overflow: visible;
}
.settings-editor .settings-list-container .monaco-list-row {
margin-left: 15px;
width: calc(100% - 15px);
}
.settings-editor .settings-body {
margin-left: -15px;
}
.settings-editor > .settings-body > .settings-list-container .settings-group-title-label {
margin: 5px 3px;
}
.settings-editor > .settings-body > .settings-list-container .settings-group-title-expanded,
.settings-editor > .settings-body > .settings-list-container .settings-group-title-collapsed {
cursor: pointer;
}
.vs-dark .settings-editor > .settings-body > .settings-list-container .settings-group-title-collapsed::before {
background-image: url(collapsed-dark.svg);
}
.settings-editor > .settings-body > .settings-list-container .settings-group-title-collapsed::before {
display: inline-block;
background-image: url(collapsed.svg);
}
.vs-dark .settings-editor > .settings-body > .settings-list-container .settings-group-title-expanded::before {
background-image: url(expanded-dark.svg);
}
.settings-editor > .settings-body > .settings-list-container .settings-group-title-expanded::before {
display: inline-block;
background-image: url(expanded.svg);
}
.settings-editor > .settings-body > .settings-list-container .settings-group-title-collapsed::before,
.settings-editor > .settings-body > .settings-list-container .settings-group-title-expanded::before {
background-size: 16px;
background-position: 50% 50%;
background-repeat: no-repeat;
width: 16px;
height: 22px;
position: absolute;
content: ' ';
left: -19px;
top: 4px;
.settings-editor > .settings-body > .settings-tree-container .settings-group-title-label {
margin: 0px;
padding: 5px 0px;
}
.settings-editor > .settings-body .settings-feedback-button {
......
......@@ -6,9 +6,9 @@
'use strict';
import * as assert from 'assert';
import { settingKeyToDisplayFormat } from 'vs/workbench/parts/preferences/browser/settingsEditor2';
import { settingKeyToDisplayFormat } from 'vs/workbench/parts/preferences/browser/settingsTree';
suite('SettingsEditor', () => {
suite('SettingsTree', () => {
test('settingKeyToDisplayFormat', () => {
assert.deepEqual(
settingKeyToDisplayFormat('foo.bar'),
......
......@@ -125,25 +125,24 @@ suite('SearchModel', () => {
assert.deepEqual(['searchResultsFirstRender', { duration: -1 }], data);
});
// test('Search Model: Search reports timed telemetry on search when progress is not called', () => {
// let target2 = sinon.spy();
// stub(nullEvent, 'stop', target2);
// let target1 = sinon.stub().returns(nullEvent);
// instantiationService.stub(ITelemetryService, 'publicLog', target1);
// instantiationService.stub(ISearchService, 'search', ppromiseWithProgress([]));
test('Search Model: Search reports timed telemetry on search when progress is not called', () => {
let target2 = sinon.spy();
stub(nullEvent, 'stop', target2);
let target1 = sinon.stub().returns(nullEvent);
instantiationService.stub(ITelemetryService, 'publicLog', target1);
// let testObject = instantiationService.createInstance(SearchModel);
// const result = testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries });
instantiationService.stub(ISearchService, 'search', ppromiseWithProgress([]));
// return timeout(1).then(() => {
// return result.then(() => {
// assert.ok(target1.calledWith('searchResultsFirstRender'));
// assert.ok(target1.calledWith('searchResultsFinished'));
// });
let testObject = instantiationService.createInstance(SearchModel);
const result = testObject.search({ contentPattern: { pattern: 'somestring' }, type: 1, folderQueries });
// });
// });
return result.then(() => {
return timeout(1).then(() => {
assert.ok(target1.calledWith('searchResultsFirstRender'));
assert.ok(target1.calledWith('searchResultsFinished'));
});
});
});
test('Search Model: Search reports timed telemetry on search when progress is called', () => {
let target2 = sinon.spy();
......
......@@ -456,6 +456,12 @@ export namespace CustomTask {
};
return result;
}
export function customizes(task: CustomTask): TaskIdentifier {
if (task._source && task._source.customizes) {
return task._source.customizes;
}
return undefined;
}
}
export interface ConfiguringTask extends CommonTask, ConfigurationProperties {
......
......@@ -696,9 +696,17 @@ class TaskService implements ITaskService {
let result: Task[] = [];
map.forEach((tasks) => {
for (let task of tasks) {
let definition = Task.getTaskDefinition(task);
if (definition && definition.type === filter.type) {
if (ContributedTask.is(task) && task.defines.type === filter.type) {
result.push(task);
} else if (CustomTask.is(task)) {
if (task.type === filter.type) {
result.push(task);
} else {
let customizes = CustomTask.customizes(task);
if (customizes && customizes.type === filter.type) {
result.push(task);
}
}
}
}
});
......
......@@ -261,13 +261,15 @@ class KeybindingItemMatches {
public readonly whenMatches: IMatch[] = null;
public readonly keybindingMatches: KeybindingMatches = null;
constructor(private modifierLabels: ModifierLabels, keybindingItem: IKeybindingItem, searchValue: string, words: string[], keybindingWords: string[], private completeMatch: boolean) {
this.commandIdMatches = this.matches(searchValue, keybindingItem.command, or(matchesWords, matchesCamelCase), words);
this.commandLabelMatches = keybindingItem.commandLabel ? this.matches(searchValue, keybindingItem.commandLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandLabel, true), words) : null;
this.commandDefaultLabelMatches = keybindingItem.commandDefaultLabel ? this.matches(searchValue, keybindingItem.commandDefaultLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandDefaultLabel, true), words) : null;
this.sourceMatches = this.matches(searchValue, keybindingItem.source, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.source, true), words);
this.whenMatches = keybindingItem.when ? this.matches(searchValue, keybindingItem.when, or(matchesWords, matchesCamelCase), words) : null;
this.keybindingMatches = keybindingItem.keybinding ? this.matchesKeybinding(keybindingItem.keybinding, searchValue, keybindingWords) : null;
constructor(private modifierLabels: ModifierLabels, keybindingItem: IKeybindingItem, searchValue: string, words: string[], keybindingWords: string[], completeMatch: boolean) {
if (!completeMatch) {
this.commandIdMatches = this.matches(searchValue, keybindingItem.command, or(matchesWords, matchesCamelCase), words);
this.commandLabelMatches = keybindingItem.commandLabel ? this.matches(searchValue, keybindingItem.commandLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandLabel, true), words) : null;
this.commandDefaultLabelMatches = keybindingItem.commandDefaultLabel ? this.matches(searchValue, keybindingItem.commandDefaultLabel, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.commandDefaultLabel, true), words) : null;
this.sourceMatches = this.matches(searchValue, keybindingItem.source, (word, wordToMatchAgainst) => matchesWords(word, keybindingItem.source, true), words);
this.whenMatches = keybindingItem.when ? this.matches(searchValue, keybindingItem.when, or(matchesWords, matchesCamelCase), words) : null;
}
this.keybindingMatches = keybindingItem.keybinding ? this.matchesKeybinding(keybindingItem.keybinding, searchValue, keybindingWords, completeMatch) : null;
}
private matches(searchValue: string, wordToMatchAgainst: string, wordMatchesFilter: IFilter, words: string[]): IMatch[] {
......@@ -299,7 +301,7 @@ class KeybindingItemMatches {
return distinct(matches, (a => a.start + '.' + a.end)).filter(match => !matches.some(m => !(m.start === match.start && m.end === match.end) && (m.start <= match.start && m.end >= match.end))).sort((a, b) => a.start - b.start);
}
private matchesKeybinding(keybinding: ResolvedKeybinding, searchValue: string, words: string[]): KeybindingMatches {
private matchesKeybinding(keybinding: ResolvedKeybinding, searchValue: string, words: string[], completeMatch: boolean): KeybindingMatches {
const [firstPart, chordPart] = keybinding.getParts();
if (strings.compareIgnoreCase(searchValue, keybinding.getAriaLabel()) === 0 || strings.compareIgnoreCase(searchValue, keybinding.getLabel()) === 0) {
......@@ -325,7 +327,7 @@ class KeybindingItemMatches {
let matchChordPart = !chordPartMatch.keyCode;
if (matchFirstPart) {
firstPartMatched = this.matchPart(firstPart, firstPartMatch, word);
firstPartMatched = this.matchPart(firstPart, firstPartMatch, word, completeMatch);
if (firstPartMatch.keyCode) {
for (const cordPartMatchedWordIndex of chordPartMatchedWords) {
if (firstPartMatchedWords.indexOf(cordPartMatchedWordIndex) === -1) {
......@@ -339,7 +341,7 @@ class KeybindingItemMatches {
}
if (matchChordPart) {
chordPartMatched = this.matchPart(chordPart, chordPartMatch, word);
chordPartMatched = this.matchPart(chordPart, chordPartMatch, word, completeMatch);
}
if (firstPartMatched) {
......@@ -357,13 +359,13 @@ class KeybindingItemMatches {
if (matchedWords.length !== words.length) {
return null;
}
if (this.completeMatch && (!this.isCompleteMatch(firstPart, firstPartMatch) || !this.isCompleteMatch(chordPart, chordPartMatch))) {
if (completeMatch && (!this.isCompleteMatch(firstPart, firstPartMatch) || !this.isCompleteMatch(chordPart, chordPartMatch))) {
return null;
}
return this.hasAnyMatch(firstPartMatch) || this.hasAnyMatch(chordPartMatch) ? { firstPart: firstPartMatch, chordPart: chordPartMatch } : null;
}
private matchPart(part: ResolvedKeybindingPart, match: KeybindingMatch, word: string): boolean {
private matchPart(part: ResolvedKeybindingPart, match: KeybindingMatch, word: string, completeMatch: boolean): boolean {
let matched = false;
if (this.matchesMetaModifier(part, word)) {
matched = true;
......@@ -381,19 +383,19 @@ class KeybindingItemMatches {
matched = true;
match.altKey = true;
}
if (this.matchesKeyCode(part, word)) {
if (this.matchesKeyCode(part, word, completeMatch)) {
match.keyCode = true;
matched = true;
}
return matched;
}
private matchesKeyCode(keybinding: ResolvedKeybindingPart, word: string): boolean {
private matchesKeyCode(keybinding: ResolvedKeybindingPart, word: string, completeMatch: boolean): boolean {
if (!keybinding) {
return false;
}
const ariaLabel = keybinding.keyAriaLabel;
if (this.completeMatch || ariaLabel.length === 1 || word.length === 1) {
if (completeMatch || ariaLabel.length === 1 || word.length === 1) {
if (strings.compareIgnoreCase(ariaLabel, word) === 0) {
return true;
}
......
......@@ -34,19 +34,19 @@ export function setup() {
await app.workbench.search.waitForResultText('10 results in 4 files');
});
it('replaces first search result with a replace term', async function () {
const app = this.app as Application;
// it('replaces first search result with a replace term', async function () {
// const app = this.app as Application;
await app.workbench.search.searchFor('body');
await app.workbench.search.expandReplace();
await app.workbench.search.setReplaceText('ydob');
await app.workbench.search.replaceFileMatch(1);
// await app.workbench.search.searchFor('body');
// await app.workbench.search.expandReplace();
// await app.workbench.search.setReplaceText('ydob');
// await app.workbench.search.replaceFileMatch(1);
await app.workbench.search.waitForResultText('10 results in 4 files');
// await app.workbench.search.waitForResultText('10 results in 4 files');
await app.workbench.search.searchFor('ydob');
await app.workbench.search.setReplaceText('body');
await app.workbench.search.replaceFileMatch(1);
});
// await app.workbench.search.searchFor('ydob');
// await app.workbench.search.setReplaceText('body');
// await app.workbench.search.replaceFileMatch(1);
// });
});
}
\ No newline at end of file
......@@ -63,6 +63,10 @@ export class Search extends Viewlet {
await this.code.waitAndClick(`${VIEWLET} .search-widget .monaco-button.toggle-replace-button.collapse`);
}
async collapseReplace(): Promise<void> {
await this.code.waitAndClick(`${VIEWLET} .search-widget .monaco-button.toggle-replace-button.expand`);
}
async setReplaceText(text: string): Promise<void> {
await this.code.waitAndClick(`${VIEWLET} .search-widget .replace-container .monaco-inputbox input[title="Replace"]`);
await this.code.waitForElement(`${VIEWLET} .search-widget .replace-container .monaco-inputbox.synthetic-focus input[title="Replace"]`);
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ISuiteCallbackContext, ITestCallbackContext } from 'mocha';
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export function describeRepeat(n: number, description: string, callback: (this: ISuiteCallbackContext) => void): void {
for (let i = 0; i < n; i++) {
describe(`${description} (iteration ${i})`, callback);
}
}
export function itRepeat(n: number, description: string, callback: (this: ITestCallbackContext, done: MochaDone) => any): void {
for (let i = 0; i < n; i++) {
it(`${description} (iteration ${i})`, callback);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册