未验证 提交 faa93507 编写于 作者: S Sandeep Somavarapu

Merge branch 'main' into sandy081/extensionsView/ux

......@@ -109,8 +109,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
......@@ -165,8 +165,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
......@@ -218,8 +218,8 @@ jobs:
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-cacheNodeModules13-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules13-
key: ${{ runner.os }}-cacheNodeModules14-${{ steps.nodeModulesCacheKey.outputs.value }}
restore-keys: ${{ runner.os }}-cacheNodeModules14-
- name: Get yarn cache directory path
id: yarnCacheDirPath
if: ${{ steps.cacheNodeModules.outputs.cache-hit != 'true' }}
......@@ -247,6 +247,9 @@ jobs:
- name: Compile /build/
run: yarn --cwd build compile
- name: Run eslint
run: yarn eslint
- name: Run Monaco Editor Checks
run: yarn monaco-compile-check
......
{
"project": "src/tsconfig.json",
"source": "./package.json",
"package": "package.json",
"out": "vscode.lsif"
}
......@@ -198,6 +198,7 @@
"type": "pwa-chrome",
"request": "launch",
"name": "Launch VS Code Internal",
"trace": true,
"windows": {
"runtimeExecutable": "${workspaceFolder}/scripts/code.bat"
},
......
disturl "https://electronjs.org/headers"
target "12.0.13"
target "13.1.6"
runtime "electron"
# Visual Studio Code - Open Source ("Code - OSS")
[![Open in Visual Studio Code](https://open.vscode.dev/badges/open-in-vscode.svg)](https://open.vscode.dev/microsoft/vscode)
[![Feature Requests](https://img.shields.io/github/issues/microsoft/vscode/feature-request.svg)](https://github.com/microsoft/vscode/issues?q=is%3Aopen+is%3Aissue+label%3Afeature-request+sort%3Areactions-%2B1-desc)
[![Bugs](https://img.shields.io/github/issues/microsoft/vscode/bug.svg)](https://github.com/microsoft/vscode/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3Abug)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-yellow.svg)](https://gitter.im/Microsoft/vscode)
......
2021-04-07T03:52:18.011Z
2021-05-26T10:17:08.678Z
......@@ -390,7 +390,7 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
reject();
}
else {
reporter(stats.toJson());
reporter(stats === null || stats === void 0 ? void 0 : stats.toJson());
}
});
}
......@@ -401,7 +401,7 @@ async function webpackExtensions(taskName, isWatch, webpackConfigLocations) {
reject();
}
else {
reporter(stats.toJson());
reporter(stats === null || stats === void 0 ? void 0 : stats.toJson());
resolve();
}
});
......
......@@ -475,7 +475,7 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
if (err) {
reject();
} else {
reporter(stats.toJson());
reporter(stats?.toJson());
}
});
} else {
......@@ -484,7 +484,7 @@ export async function webpackExtensions(taskName: string, isWatch: boolean, webp
fancyLog.error(err);
reject();
} else {
reporter(stats.toJson());
reporter(stats?.toJson());
resolve();
}
});
......
......@@ -46,6 +46,10 @@
"name": "vs/workbench/contrib/callHierarchy",
"project": "vscode-workbench"
},
{
"name": "vs/workbench/contrib/typeHierarchy",
"project": "vscode-workbench"
},
{
"name": "vs/workbench/contrib/codeActions",
"project": "vscode-workbench"
......
......@@ -33,7 +33,6 @@ module.exports = {
stats: {
all: false,
modules: true,
maxModules: 0,
errors: true,
warnings: true,
// our additional options
......
......@@ -57,7 +57,7 @@
"plist": "^3.0.1",
"source-map": "0.6.1",
"tmp": "^0.2.1",
"typescript": "^4.4.0-dev.20210708",
"typescript": "^4.4.0-dev.20210713",
"vsce": "1.48.0",
"vscode-universal": "deepak1556/universal#61454d96223b774c53cda10f72c2098c0ce02d58"
},
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
function format(message, args) {
let result;
// if (isPseudo) {
// // FF3B and FF3D is the Unicode zenkaku representation for [ and ]
// message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D';
// }
if (args.length === 0) {
result = message;
}
else {
result = message.replace(/\{(\d+)\}/g, function (match, rest) {
let index = rest[0];
let arg = args[index];
let replacement = match;
if (typeof arg === 'string') {
replacement = arg;
}
else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {
replacement = String(arg);
}
return replacement;
});
}
return result;
}
function localize(key, message) {
let args = [];
for (let _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
return format(message, args);
}
function loadMessageBundle(file) {
return localize;
}
let MessageFormat;
(function (MessageFormat) {
MessageFormat["file"] = "file";
MessageFormat["bundle"] = "bundle";
MessageFormat["both"] = "both";
})(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {}));
let BundleFormat;
(function (BundleFormat) {
// the nls.bundle format
BundleFormat["standalone"] = "standalone";
BundleFormat["languagePack"] = "languagePack";
})(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {}));
exports.loadMessageBundle = loadMessageBundle;
function config(opts) {
if (opts) {
if (isString(opts.locale)) {
options.locale = opts.locale.toLowerCase();
options.language = options.locale;
resolvedLanguage = undefined;
resolvedBundles = Object.create(null);
}
if (opts.messageFormat !== undefined) {
options.messageFormat = opts.messageFormat;
}
if (opts.bundleFormat === BundleFormat.standalone && options.languagePackSupport === true) {
options.languagePackSupport = false;
}
}
isPseudo = options.locale === 'pseudo';
return loadMessageBundle;
}
exports.config = config;
......@@ -2047,10 +2047,10 @@ typescript@^4.1.3:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.1.3.tgz#519d582bd94cba0cf8934c7d8e8467e473f53bb7"
integrity sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==
typescript@^4.4.0-dev.20210708:
version "4.4.0-dev.20210708"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.0-dev.20210708.tgz#0043aa6d3b81c111c6215477a31774b5a864e7e1"
integrity sha512-jGNamsvrU8F8KjMawCauI7bQeUPKYdyIp4yiEsKv8Uk1gt494FN09wgtH9wbbT0qK7a7lel7A/N/DodpPWK/6Q==
typescript@^4.4.0-dev.20210713:
version "4.4.0-dev.20210713"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.4.0-dev.20210713.tgz#80e5d4c550e464e6aad8c0e2aa4cf42d67ce549d"
integrity sha512-Z8zYMhAwLa7mpc3LP3Z+fOTmXsRqkvgepB+dEg08g9tI9B+kR0izmPZOlcfBN7GlyxmZe5qpnnGmkhxZeHxa3g==
uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.5"
......
......@@ -6,7 +6,7 @@
"git": {
"name": "chromium",
"repositoryUrl": "https://chromium.googlesource.com/chromium/src",
"commitHash": "cd7a46bf02a768a1aabf9443f6ee469bc6e28e7c"
"commitHash": "7a7e35991d61ce564ed3641222da2c4ed7a65535"
}
},
"licenseDetail": [
......@@ -40,7 +40,7 @@
"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
],
"isOnlyProductionDependency": true,
"version": "89.0.4389.128"
"version": "91.0.4472.124"
},
{
"component": {
......@@ -60,12 +60,12 @@
"git": {
"name": "electron",
"repositoryUrl": "https://github.com/electron/electron",
"commitHash": "14ae30aa9b2619358298b525acd398446b385151"
"commitHash": "ddc44e1af4fa6bf0c4c05f3dd48270ef308bc470"
}
},
"isOnlyProductionDependency": true,
"license": "MIT",
"version": "12.0.13"
"version": "13.1.6"
},
{
"component": {
......
......@@ -21,7 +21,7 @@
},
"dependencies": {
"jsonc-parser": "^2.2.1",
"vscode-nls": "^4.1.1"
"vscode-nls": "^5.0.0"
},
"capabilities": {
"virtualWorkspaces": true,
......
......@@ -12,7 +12,7 @@ jsonc-parser@^2.2.1:
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.2.1.tgz#db73cd59d78cce28723199466b2a03d1be1df2bc"
integrity sha512-o6/yDBYccGvTz1+QFevz6l6OBZ2+fMVu2JZ9CIhzsYRX4mjaK5IyX9eldUdCmga16zlgQxyrj5pt9kzuj2C02w==
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -18,6 +18,7 @@ module.exports = withBrowserDefaults({
output: {
filename: 'cssServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
libraryTarget: 'var'
libraryTarget: 'var',
library: 'serverExportVar'
}
});
......@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
import { startServer } from '../cssServer';
import { createConnection, BrowserMessageReader, BrowserMessageWriter, Disposable } from 'vscode-languageserver/browser';
import { RuntimeEnvironment, startServer } from '../cssServer';
declare let self: any;
......@@ -13,4 +13,17 @@ const messageWriter = new BrowserMessageWriter(self);
const connection = createConnection(messageReader, messageWriter);
startServer(connection, {});
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setTimeout(callback, 0, ...args);
return { dispose: () => clearTimeout(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
}
};
startServer(connection, runtime);
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import {
Connection, TextDocuments, InitializeParams, InitializeResult, ServerCapabilities, ConfigurationRequest, WorkspaceFolder, TextDocumentSyncKind, NotificationType
Connection, TextDocuments, InitializeParams, InitializeResult, ServerCapabilities, ConfigurationRequest, WorkspaceFolder, TextDocumentSyncKind, NotificationType, Disposable
} from 'vscode-languageserver';
import { URI } from 'vscode-uri';
import { getCSSLanguageService, getSCSSLanguageService, getLESSLanguageService, LanguageSettings, LanguageService, Stylesheet, TextDocument, Position } from 'vscode-css-languageservice';
......@@ -25,8 +25,12 @@ export interface Settings {
}
export interface RuntimeEnvironment {
file?: RequestService;
http?: RequestService
readonly file?: RequestService;
readonly http?: RequestService;
readonly timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable;
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
}
}
export function startServer(connection: Connection, runtime: RuntimeEnvironment) {
......@@ -150,7 +154,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
documents.all().forEach(triggerValidation);
}
const pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
const pendingValidationRequests: { [uri: string]: Disposable } = {};
const validationDelayMs = 500;
// The content of a text document has changed. This event is emitted
......@@ -168,14 +172,14 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
function cleanPendingValidation(textDocument: TextDocument): void {
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
request.dispose();
delete pendingValidationRequests[textDocument.uri];
}
}
function triggerValidation(textDocument: TextDocument): void {
cleanPendingValidation(textDocument);
pendingValidationRequests[textDocument.uri] = setTimeout(() => {
pendingValidationRequests[textDocument.uri] = runtime.timer.setTimeout(() => {
delete pendingValidationRequests[textDocument.uri];
validateTextDocument(textDocument);
}, validationDelayMs);
......@@ -203,7 +207,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onCompletion((textDocumentPosition, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const [settings,] = await Promise.all([getDocumentSettings(document), dataProvidersReady]);
......@@ -216,7 +220,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onHover((textDocumentPosition, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const [settings,] = await Promise.all([getDocumentSettings(document), dataProvidersReady]);
......@@ -228,7 +232,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentSymbol((documentSymbolParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -240,7 +244,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDefinition((documentDefinitionParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(documentDefinitionParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -252,7 +256,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentHighlight((documentHighlightParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(documentHighlightParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -265,7 +269,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
connection.onDocumentLinks(async (documentLinkParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(documentLinkParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -279,7 +283,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
connection.onReferences((referenceParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(referenceParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -291,7 +295,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onCodeAction((codeActionParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(codeActionParams.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -303,7 +307,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentColor((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -315,7 +319,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onColorPresentation((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -327,7 +331,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRenameRequest((renameParameters, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(renameParameters.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -339,7 +343,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onFoldingRanges((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
await dataProvidersReady;
......@@ -350,7 +354,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onSelectionRanges((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
const positions: Position[] = params.positions;
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TextDocument } from 'vscode-languageserver';
import { TextDocument } from 'vscode-css-languageservice';
export interface LanguageModelCache<T> {
get(document: TextDocument): T;
......@@ -79,4 +79,4 @@ export function getLanguageModelCache<T>(maxEntries: number, cleanupIntervalTime
}
}
};
}
\ No newline at end of file
}
......@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, Connection } from 'vscode-languageserver/node';
import { createConnection, Connection, Disposable } from 'vscode-languageserver/node';
import { formatError } from '../utils/runner';
import { startServer } from '../cssServer';
import { RuntimeEnvironment, startServer } from '../cssServer';
import { getNodeFSRequestService } from './nodeFs';
// Create a connection for the server.
......@@ -18,4 +18,18 @@ process.on('unhandledRejection', (e: any) => {
connection.console.error(formatError(`Unhandled exception`, e));
});
startServer(connection, { file: getNodeFSRequestService() });
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setImmediate(callback, ...args);
return { dispose: () => clearImmediate(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
},
file: getNodeFSRequestService()
};
startServer(connection, runtime);
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { ResponseError, CancellationToken, LSPErrorCodes } from 'vscode-languageserver';
import { RuntimeEnvironment } from '../cssServer';
export function formatError(message: string, err: any): string {
if (err instanceof Error) {
......@@ -17,9 +18,9 @@ export function formatError(message: string, err: any): string {
return message;
}
export function runSafeAsync<T>(func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
export function runSafeAsync<T>(runtime: RuntimeEnvironment, func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
return new Promise<T | ResponseError<any>>((resolve) => {
setImmediate(() => {
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
}
......
......@@ -30,7 +30,7 @@
"jsonc-parser": "^2.2.1",
"markdown-it": "^12.0.4",
"parse5": "^3.0.2",
"vscode-nls": "^4.1.1"
"vscode-nls": "^5.0.0"
},
"contributes": {
"jsonValidation": [
......
......@@ -18,4 +18,5 @@ function registerPackageDocumentCompletions(): vscode.Disposable {
return new PackageDocument(document).provideCompletionItems(position, token);
}
});
}
......@@ -72,7 +72,7 @@ uc.micro@^1.0.5:
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
integrity sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -88,7 +88,7 @@
"node-fetch": "2.6.1",
"uuid": "8.1.0",
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.1.2",
"vscode-nls": "^5.0.0",
"vscode-tas-client": "^0.1.22"
},
"devDependencies": {
......
......@@ -175,10 +175,10 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
vscode-tas-client@^0.1.22:
version "0.1.22"
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ExtensionContext, Uri } from 'vscode';
import { Disposable, ExtensionContext, Uri } from 'vscode';
import { LanguageClientOptions } from 'vscode-languageclient';
import { startClient, LanguageClientConstructor } from '../htmlClient';
import { LanguageClient } from 'vscode-languageclient/browser';
......@@ -24,7 +24,14 @@ export function activate(context: ExtensionContext) {
return new LanguageClient(id, name, clientOptions, worker);
};
startClient(context, newLanguageClient, { TextDecoder });
const timer = {
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
};
startClient(context, newLanguageClient, { TextDecoder, timer });
} catch (e) {
console.log(e);
......
......@@ -58,6 +58,9 @@ export interface Runtime {
TextDecoder: { new(encoding?: string): { decode(buffer: ArrayBuffer): string; } };
fs?: RequestService;
telemetry?: TelemetryReporter;
readonly timer: {
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
}
}
export function startClient(context: ExtensionContext, newLanguageClient: LanguageClientConstructor, runtime: Runtime) {
......@@ -126,7 +129,7 @@ export function startClient(context: ExtensionContext, newLanguageClient: Langua
let param = client.code2ProtocolConverter.asTextDocumentPositionParams(document, position);
return client.sendRequest(TagCloseRequest.type, param);
};
disposable = activateTagClosing(tagRequestor, { html: true, handlebars: true }, 'html.autoClosingTags');
disposable = activateTagClosing(tagRequestor, { html: true, handlebars: true }, 'html.autoClosingTags', runtime);
toDispose.push(disposable);
disposable = client.onTelemetry(e => {
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { getNodeFSRequestService } from './nodeFs';
import { ExtensionContext } from 'vscode';
import { Disposable, ExtensionContext } from 'vscode';
import { startClient, LanguageClientConstructor } from '../htmlClient';
import { ServerOptions, TransportKind, LanguageClientOptions, LanguageClient } from 'vscode-languageclient/node';
import { TextDecoder } from 'util';
......@@ -37,7 +37,14 @@ export function activate(context: ExtensionContext) {
return new LanguageClient(id, name, serverOptions, clientOptions);
};
startClient(context, newLanguageClient, { fs: getNodeFSRequestService(), TextDecoder, telemetry });
const timer = {
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
};
startClient(context, newLanguageClient, { fs: getNodeFSRequestService(), TextDecoder, telemetry, timer });
}
interface IPackageInfo {
......
......@@ -4,8 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import { window, workspace, Disposable, TextDocumentContentChangeEvent, TextDocument, Position, SnippetString } from 'vscode';
import { Runtime } from './htmlClient';
export function activateTagClosing(tagProvider: (document: TextDocument, position: Position) => Thenable<string>, supportedLanguages: { [id: string]: boolean }, configName: string): Disposable {
export function activateTagClosing(tagProvider: (document: TextDocument, position: Position) => Thenable<string>, supportedLanguages: { [id: string]: boolean }, configName: string, runtime: Runtime): Disposable {
let disposables: Disposable[] = [];
workspace.onDidChangeTextDocument(event => onDidChangeTextDocument(event.document, event.contentChanges), null, disposables);
......@@ -14,7 +15,13 @@ export function activateTagClosing(tagProvider: (document: TextDocument, positio
updateEnabledState();
window.onDidChangeActiveTextEditor(updateEnabledState, null, disposables);
let timeout: NodeJS.Timer | undefined = undefined;
let timeout: Disposable | undefined = undefined;
disposables.push({
dispose: () => {
timeout?.dispose();
}
});
function updateEnabledState() {
isEnabled = false;
......@@ -40,8 +47,8 @@ export function activateTagClosing(tagProvider: (document: TextDocument, positio
if (document !== activeDocument || changes.length === 0) {
return;
}
if (typeof timeout !== 'undefined') {
clearTimeout(timeout);
if (timeout) {
timeout.dispose();
}
let lastChange = changes[changes.length - 1];
let lastCharacter = lastChange.text[lastChange.text.length - 1];
......@@ -50,7 +57,7 @@ export function activateTagClosing(tagProvider: (document: TextDocument, positio
}
let rangeStart = lastChange.range.start;
let version = document.version;
timeout = setTimeout(() => {
timeout = runtime.timer.setTimeout(() => {
let position = new Position(rangeStart.line, rangeStart.character + lastChange.text.length);
tagProvider(document, position).then(text => {
if (text && isEnabled) {
......@@ -72,4 +79,4 @@ export function activateTagClosing(tagProvider: (document: TextDocument, positio
}, 100);
}
return Disposable.from(...disposables);
}
\ No newline at end of file
}
......@@ -18,7 +18,8 @@ const serverConfig = withBrowserDefaults({
output: {
filename: 'htmlServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
libraryTarget: 'var'
libraryTarget: 'var',
library: 'serverExportVar'
},
optimization: {
splitChunks: {
......@@ -26,7 +27,7 @@ const serverConfig = withBrowserDefaults({
}
}
});
serverConfig.module.noParse = /typescript[\/\\]lib[\/\\]typescript\.js/;
serverConfig.module.noParse = /typescript[\/\\]lib[\/\\]typescript\.js/;
serverConfig.module.rules.push({
test: /javascriptLibs.ts$/,
use: [
......
......@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
import { startServer } from '../htmlServer';
import { createConnection, BrowserMessageReader, BrowserMessageWriter, Disposable } from 'vscode-languageserver/browser';
import { RuntimeEnvironment, startServer } from '../htmlServer';
declare let self: any;
......@@ -13,4 +13,17 @@ const messageWriter = new BrowserMessageWriter(self);
const connection = createConnection(messageReader, messageWriter);
startServer(connection, {});
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setTimeout(callback, 0, ...args);
return { dispose: () => clearTimeout(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
}
};
startServer(connection, runtime);
......@@ -50,6 +50,10 @@ export interface RuntimeEnvironment {
file?: RequestService;
http?: RequestService
configureHttpRequests?(proxy: string, strictSSL: boolean): void;
readonly timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable;
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
}
}
export function startServer(connection: Connection, runtime: RuntimeEnvironment) {
......@@ -215,7 +219,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
});
const pendingValidationRequests: { [uri: string]: NodeJS.Timer } = {};
const pendingValidationRequests: { [uri: string]: Disposable } = {};
const validationDelayMs = 500;
// The content of a text document has changed. This event is emitted
......@@ -233,14 +237,14 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
function cleanPendingValidation(textDocument: TextDocument): void {
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
request.dispose();
delete pendingValidationRequests[textDocument.uri];
}
}
function triggerValidation(textDocument: TextDocument): void {
cleanPendingValidation(textDocument);
pendingValidationRequests[textDocument.uri] = setTimeout(() => {
pendingValidationRequests[textDocument.uri] = runtime.timer.setTimeout(() => {
delete pendingValidationRequests[textDocument.uri];
validateTextDocument(textDocument);
}, validationDelayMs);
......@@ -277,7 +281,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onCompletion(async (textDocumentPosition, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (!document) {
return null;
......@@ -305,7 +309,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onCompletionResolve((item, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const data = item.data;
if (data && data.languageId && data.uri) {
const mode = languageModes.getMode(data.languageId);
......@@ -319,7 +323,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onHover((textDocumentPosition, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, textDocumentPosition.position);
......@@ -334,7 +338,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentHighlight((documentHighlightParams, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(documentHighlightParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, documentHighlightParams.position);
......@@ -347,7 +351,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDefinition((definitionParams, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(definitionParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, definitionParams.position);
......@@ -360,7 +364,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onReferences((referenceParams, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(referenceParams.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, referenceParams.position);
......@@ -373,7 +377,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onSignatureHelp((signatureHelpParms, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(signatureHelpParms.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, signatureHelpParms.position);
......@@ -401,15 +405,15 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onDocumentRangeFormatting((formatParams, token) => {
return runSafe(() => onFormat(formatParams.textDocument, formatParams.range, formatParams.options), [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
return runSafe(runtime, () => onFormat(formatParams.textDocument, formatParams.range, formatParams.options), [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentFormatting((formatParams, token) => {
return runSafe(() => onFormat(formatParams.textDocument, undefined, formatParams.options), [], `Error while formatting ${formatParams.textDocument.uri}`, token);
return runSafe(runtime, () => onFormat(formatParams.textDocument, undefined, formatParams.options), [], `Error while formatting ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentLinks((documentLinkParam, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(documentLinkParam.textDocument.uri);
const links: DocumentLink[] = [];
if (document) {
......@@ -425,7 +429,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentSymbol((documentSymbolParms, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(documentSymbolParms.textDocument.uri);
const symbols: SymbolInformation[] = [];
if (document) {
......@@ -440,7 +444,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRequest(DocumentColorRequest.type, (params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const infos: ColorInformation[] = [];
const document = documents.get(params.textDocument.uri);
if (document) {
......@@ -455,7 +459,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRequest(ColorPresentationRequest.type, (params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const mode = languageModes.getModeAtPosition(document, params.range.start);
......@@ -468,7 +472,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRequest(TagCloseRequest.type, (params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const pos = params.position;
......@@ -484,7 +488,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onFoldingRanges((params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
return getFoldingRanges(languageModes, document, foldingRangeLimit, token);
......@@ -494,7 +498,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onSelectionRanges((params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
return getSelectionRanges(languageModes, document, params.positions);
......@@ -504,7 +508,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRenameRequest((params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
const position: Position = params.position;
......@@ -520,7 +524,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.languages.onLinkedEditingRange((params, token) => {
return <any> /* todo remove when microsoft/vscode-languageserver-node#700 fixed */ runSafe(async () => {
return <any> /* todo remove when microsoft/vscode-languageserver-node#700 fixed */ runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const pos = params.position;
......@@ -547,7 +551,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onRequest(SemanticTokenRequest.type, (params, token) => {
return runSafe(async () => {
return runSafe(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
return getSemanticTokenProvider().getSemanticTokens(document, params.ranges);
......@@ -557,7 +561,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onRequest(SemanticTokenLegendRequest.type, token => {
return runSafe(async () => {
return runSafe(runtime, async () => {
return getSemanticTokenProvider().legend;
}, null, `Error while computing semantic tokens legend`, token);
});
......
......@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, Connection } from 'vscode-languageserver/node';
import { createConnection, Connection, Disposable } from 'vscode-languageserver/node';
import { formatError } from '../utils/runner';
import { startServer } from '../htmlServer';
import { RuntimeEnvironment, startServer } from '../htmlServer';
import { getNodeFSRequestService } from './nodeFs';
......@@ -19,5 +19,18 @@ process.on('unhandledRejection', (e: any) => {
connection.console.error(formatError(`Unhandled exception`, e));
});
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setImmediate(callback, ...args);
return { dispose: () => clearImmediate(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
},
file: getNodeFSRequestService()
};
startServer(connection, { file: getNodeFSRequestService() });
startServer(connection, runtime);
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { ResponseError, CancellationToken, LSPErrorCodes } from 'vscode-languageserver';
import { RuntimeEnvironment } from '../htmlServer';
export function formatError(message: string, err: any): string {
if (err instanceof Error) {
......@@ -17,9 +18,9 @@ export function formatError(message: string, err: any): string {
return message;
}
export function runSafe<T>(func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
export function runSafe<T>(runtime: RuntimeEnvironment, func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
return new Promise<T | ResponseError<any>>((resolve) => {
setImmediate(() => {
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
}
......
......@@ -82,7 +82,7 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.0.0"
"vscode-nls": "^5.0.0"
},
"repository": {
"type": "git",
......
......@@ -90,7 +90,7 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -9,7 +9,6 @@
const withDefaults = require('../shared.webpack.config');
const path = require('path');
const webpack = require('webpack');
const config = withDefaults({
context: path.join(__dirname, 'client'),
......@@ -22,7 +21,5 @@ const config = withDefaults({
}
});
// add plugin, don't replace inherited
config.plugins.push(new webpack.IgnorePlugin(/vertx/)); // request-light dependency
module.exports = config;
......@@ -134,7 +134,7 @@
]
},
"dependencies": {
"request-light": "^0.4.0",
"request-light": "^0.5.3",
"vscode-extension-telemetry": "0.1.7",
"vscode-languageclient": "^7.0.0",
"vscode-nls": "^5.0.0"
......
......@@ -18,6 +18,7 @@ module.exports = withBrowserDefaults({
output: {
filename: 'jsonServerMain.js',
path: path.join(__dirname, 'dist', 'browser'),
libraryTarget: 'var'
libraryTarget: 'var',
library: 'serverExportVar'
}
});
......@@ -9,7 +9,6 @@
const withDefaults = require('../../shared.webpack.config');
const path = require('path');
const webpack = require('webpack');
const config = withDefaults({
context: path.join(__dirname),
......@@ -22,7 +21,4 @@ const config = withDefaults({
}
});
// add plugin, don't replace inherited
config.plugins.push(new webpack.IgnorePlugin(/vertx/)); // request-light dependency
module.exports = config;
......@@ -13,7 +13,7 @@
"main": "./out/node/jsonServerMain",
"dependencies": {
"jsonc-parser": "^3.0.0",
"request-light": "^0.4.0",
"request-light": "^0.5.3",
"vscode-json-languageservice": "^4.1.5",
"vscode-languageserver": "^7.0.0",
"vscode-uri": "^3.0.2"
......
......@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
import { startServer } from '../jsonServer';
import { createConnection, BrowserMessageReader, BrowserMessageWriter, Disposable } from 'vscode-languageserver/browser';
import { RuntimeEnvironment, startServer } from '../jsonServer';
declare let self: any;
......@@ -13,4 +13,17 @@ const messageWriter = new BrowserMessageWriter(self);
const connection = createConnection(messageReader, messageWriter);
startServer(connection, {});
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setTimeout(callback, 0, ...args);
return { dispose: () => clearTimeout(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
}
};
startServer(connection, runtime);
......@@ -48,6 +48,10 @@ export interface RuntimeEnvironment {
file?: RequestService;
http?: RequestService
configureHttpRequests?(proxy: string, strictSSL: boolean): void;
readonly timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable;
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable;
}
}
export function startServer(connection: Connection, runtime: RuntimeEnvironment) {
......@@ -171,13 +175,19 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
const limitExceededWarnings = function () {
const pendingWarnings: { [uri: string]: { features: { [name: string]: string }; timeout?: NodeJS.Timeout; } } = {};
const pendingWarnings: { [uri: string]: { features: { [name: string]: string }; timeout?: Disposable; } } = {};
const showLimitedNotification = (uri: string, resultLimit: number) => {
const warning = pendingWarnings[uri];
connection.sendNotification(ResultLimitReachedNotification.type, `${basename(uri)}: For performance reasons, ${Object.keys(warning.features).join(' and ')} have been limited to ${resultLimit} items.`);
warning.timeout = undefined;
};
return {
cancel(uri: string) {
const warning = pendingWarnings[uri];
if (warning && warning.timeout) {
clearTimeout(warning.timeout);
warning.timeout.dispose();
delete pendingWarnings[uri];
}
},
......@@ -191,13 +201,11 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
return;
}
warning.features[name] = name;
warning.timeout.refresh();
warning.timeout.dispose();
warning.timeout = runtime.timer.setTimeout(() => showLimitedNotification(uri, resultLimit), 2000);
} else {
warning = { features: { [name]: name } };
warning.timeout = setTimeout(() => {
connection.sendNotification(ResultLimitReachedNotification.type, `${basename(uri)}: For performance reasons, ${Object.keys(warning.features).join(' and ')} have been limited to ${resultLimit} items.`);
warning.timeout = undefined;
}, 2000);
warning.timeout = runtime.timer.setTimeout(() => showLimitedNotification(uri, resultLimit), 2000);
pendingWarnings[uri] = warning;
}
};
......@@ -316,20 +324,20 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
});
const pendingValidationRequests: { [uri: string]: NodeJS.Timer; } = {};
const pendingValidationRequests: { [uri: string]: Disposable; } = {};
const validationDelayMs = 300;
function cleanPendingValidation(textDocument: TextDocument): void {
const request = pendingValidationRequests[textDocument.uri];
if (request) {
clearTimeout(request);
request.dispose();
delete pendingValidationRequests[textDocument.uri];
}
}
function triggerValidation(textDocument: TextDocument): void {
cleanPendingValidation(textDocument);
pendingValidationRequests[textDocument.uri] = setTimeout(() => {
pendingValidationRequests[textDocument.uri] = runtime.timer.setTimeout(() => {
delete pendingValidationRequests[textDocument.uri];
validateTextDocument(textDocument);
}, validationDelayMs);
......@@ -351,7 +359,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'warning' } : { comments: 'error', trailingCommas: 'error' };
languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
setImmediate(() => {
runtime.timer.setImmediate(() => {
const currDocument = documents.get(textDocument.uri);
if (currDocument && currDocument.version === version) {
respond(diagnostics); // Send the computed diagnostics to VSCode.
......@@ -388,7 +396,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onCompletion((textDocumentPosition, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(textDocumentPosition.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......@@ -399,7 +407,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onHover((textDocumentPositionParams, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(textDocumentPositionParams.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......@@ -410,7 +418,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentSymbol((documentSymbolParams, token) => {
return runSafe(() => {
return runSafe(runtime, () => {
const document = documents.get(documentSymbolParams.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......@@ -439,15 +447,15 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
}
connection.onDocumentRangeFormatting((formatParams, token) => {
return runSafe(() => onFormat(formatParams.textDocument, formatParams.range, formatParams.options), [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
return runSafe(runtime, () => onFormat(formatParams.textDocument, formatParams.range, formatParams.options), [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentFormatting((formatParams, token) => {
return runSafe(() => onFormat(formatParams.textDocument, undefined, formatParams.options), [], `Error while formatting ${formatParams.textDocument.uri}`, token);
return runSafe(runtime, () => onFormat(formatParams.textDocument, undefined, formatParams.options), [], `Error while formatting ${formatParams.textDocument.uri}`, token);
});
connection.onDocumentColor((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const onResultLimitExceeded = limitExceededWarnings.onResultLimitExceeded(document.uri, resultLimit, 'document colors');
......@@ -459,7 +467,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onColorPresentation((params, token) => {
return runSafe(() => {
return runSafe(runtime, () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......@@ -470,7 +478,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onFoldingRanges((params, token) => {
return runSafe(() => {
return runSafe(runtime, () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const onRangeLimitExceeded = limitExceededWarnings.onResultLimitExceeded(document.uri, foldingRangeLimit, 'folding ranges');
......@@ -482,7 +490,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
connection.onSelectionRanges((params, token) => {
return runSafe(() => {
return runSafe(runtime, () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......@@ -493,7 +501,7 @@ export function startServer(connection: Connection, runtime: RuntimeEnvironment)
});
connection.onDocumentLinks((params, token) => {
return runSafeAsync(async () => {
return runSafeAsync(runtime, async () => {
const document = documents.get(params.textDocument.uri);
if (document) {
const jsonDocument = getJSONDocument(document);
......
......@@ -3,9 +3,9 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createConnection, Connection } from 'vscode-languageserver/node';
import { createConnection, Connection, Disposable } from 'vscode-languageserver/node';
import { formatError } from '../utils/runner';
import { startServer } from '../jsonServer';
import { RuntimeEnvironment, startServer } from '../jsonServer';
import { RequestService } from '../requests';
import { xhr, XHRResponse, configure as configureHttpRequests, getErrorStatusDescription } from 'request-light';
......@@ -51,5 +51,22 @@ function getFileRequestService(): RequestService {
};
}
const runtime: RuntimeEnvironment = {
timer: {
setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
const handle = setImmediate(callback, ...args);
return { dispose: () => clearImmediate(handle) };
},
setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): Disposable {
const handle = setTimeout(callback, ms, ...args);
return { dispose: () => clearTimeout(handle) };
}
},
file: getFileRequestService(),
http: getHTTPRequestService(),
configureHttpRequests
};
startServer(connection, { file: getFileRequestService(), http: getHTTPRequestService(), configureHttpRequests });
startServer(connection, runtime);
......@@ -4,6 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { CancellationToken, ResponseError, LSPErrorCodes } from 'vscode-languageserver';
import { RuntimeEnvironment } from '../jsonServer';
export function formatError(message: string, err: any): string {
if (err instanceof Error) {
......@@ -17,9 +18,9 @@ export function formatError(message: string, err: any): string {
return message;
}
export function runSafeAsync<T>(func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
export function runSafeAsync<T>(runtime: RuntimeEnvironment, func: () => Thenable<T>, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<any>> {
return new Promise<T | ResponseError<any>>((resolve) => {
setImmediate(() => {
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
}
......@@ -38,9 +39,9 @@ export function runSafeAsync<T>(func: () => Thenable<T>, errorVal: T, errorMessa
});
}
export function runSafe<T, E>(func: () => T, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<E>> {
export function runSafe<T, E>(runtime: RuntimeEnvironment, func: () => T, errorVal: T, errorMessage: string, token: CancellationToken): Thenable<T | ResponseError<E>> {
return new Promise<T | ResponseError<E>>((resolve) => {
setImmediate(() => {
runtime.timer.setImmediate(() => {
if (token.isCancellationRequested) {
resolve(cancelValue());
} else {
......
......@@ -12,20 +12,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.43.tgz#26bcbb0595b305400e8ceaf9a127a7f905ae49c8"
integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==
agent-base@4:
version "4.1.2"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.1.2.tgz#80fa6cde440f4dcf9af2617cf246099b5d99f0c8"
integrity sha512-VE6QoEdaugY86BohRtfGmTDabxdU5sCKOkbcPA6PXKJsRzEi/7A3RCTxJal1ft/4qSfPht5/iQLhMh/wzSkkNw==
dependencies:
es6-promisify "^5.0.0"
agent-base@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
dependencies:
es6-promisify "^5.0.0"
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
......@@ -44,41 +30,6 @@ concat-map@0.0.1:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
debug@3.1.0, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"
es6-promise@^4.0.3:
version "4.1.1"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.1.1.tgz#8811e90915d9a0dba36274f0b242dbda78f9c92a"
integrity sha512-OaU1hHjgJf+b0NzsxCg7NdIYERD6Hy/PEmFLTjw+b65scuisG3Kt4QoTvJ66BBkPZ581gr0kpoVzKnxniM8nng==
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
dependencies:
es6-promise "^4.0.3"
http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==
dependencies:
agent-base "4"
debug "3.1.0"
https-proxy-agent@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==
dependencies:
agent-base "^4.3.0"
debug "^3.1.0"
jsonc-parser@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.0.0.tgz#abdd785701c7e7eaca8a9ec8cf070ca51a745a22"
......@@ -91,19 +42,10 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
request-light@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.4.0.tgz#c6b91ef00b18cb0de75d2127e55b3a2c9f7f90f9"
integrity sha512-fimzjIVw506FBZLspTAXHdpvgvQebyjpNyLRd0e6drPPRq7gcrROeGWRyF81wLqFg5ijPgnOQbmfck5wdTqpSA==
dependencies:
http-proxy-agent "^2.1.0"
https-proxy-agent "^2.2.4"
vscode-nls "^4.1.2"
request-light@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.5.3.tgz#bc5b103b939cde7c0653fff8ab4f43440779a5fb"
integrity sha512-wlHI5WbSZ2PcoLW2qE616PKDFCFJWaJjgRg2VaNXF9pa8MJ7+dKveJzw2HhJF8Et5uOmh9nAUJUX4iFI3Mvm/g==
vscode-json-languageservice@^4.1.5:
version "4.1.5"
......@@ -147,11 +89,6 @@ vscode-languageserver@^7.0.0:
dependencies:
vscode-languageserver-protocol "3.16.0"
vscode-nls@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
......
......@@ -7,20 +7,6 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.43.tgz#26bcbb0595b305400e8ceaf9a127a7f905ae49c8"
integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==
agent-base@4:
version "4.2.1"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.1.tgz#d89e5999f797875674c07d87f260fc41e83e8ca9"
integrity sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==
dependencies:
es6-promisify "^5.0.0"
agent-base@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
dependencies:
es6-promisify "^5.0.0"
applicationinsights@1.7.4:
version "1.7.4"
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.7.4.tgz#e7d96435594d893b00cf49f70a5927105dbb8749"
......@@ -81,20 +67,6 @@ continuation-local-storage@^3.2.1:
async-listener "^0.6.0"
emitter-listener "^1.1.1"
debug@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"
debug@^3.1.0:
version "3.2.6"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b"
integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==
dependencies:
ms "^2.1.1"
diagnostic-channel-publishers@^0.3.3:
version "0.3.5"
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.3.5.tgz#a84a05fd6cc1d7619fdd17791c17e540119a7536"
......@@ -114,34 +86,6 @@ emitter-listener@^1.0.1, emitter-listener@^1.1.1:
dependencies:
shimmer "^1.2.0"
es6-promise@^4.0.3:
version "4.2.6"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.6.tgz#b685edd8258886365ea62b57d30de28fadcd974f"
integrity sha512-aRVgGdnmW2OiySVPUC9e6m+plolMAJKjZnQlCwNSuK5yQ0JN61DZSO1X1Ufd1foqWRAlig0rhduTCHe7sVtK5Q==
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
dependencies:
es6-promise "^4.0.3"
http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==
dependencies:
agent-base "4"
debug "3.1.0"
https-proxy-agent@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==
dependencies:
agent-base "^4.3.0"
debug "^3.1.0"
lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
......@@ -156,24 +100,10 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
ms@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a"
integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==
request-light@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.4.0.tgz#c6b91ef00b18cb0de75d2127e55b3a2c9f7f90f9"
integrity sha512-fimzjIVw506FBZLspTAXHdpvgvQebyjpNyLRd0e6drPPRq7gcrROeGWRyF81wLqFg5ijPgnOQbmfck5wdTqpSA==
dependencies:
http-proxy-agent "^2.1.0"
https-proxy-agent "^2.2.4"
vscode-nls "^4.1.2"
request-light@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.5.3.tgz#bc5b103b939cde7c0653fff8ab4f43440779a5fb"
integrity sha512-wlHI5WbSZ2PcoLW2qE616PKDFCFJWaJjgRg2VaNXF9pa8MJ7+dKveJzw2HhJF8Et5uOmh9nAUJUX4iFI3Mvm/g==
semver@^5.3.0:
version "5.5.0"
......@@ -236,11 +166,6 @@ vscode-languageserver-types@3.16.0:
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247"
integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA==
vscode-nls@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
......
......@@ -356,7 +356,7 @@
"markdown-it": "^12.0.3",
"markdown-it-front-matter": "^0.2.1",
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.0.0"
"vscode-nls": "^5.0.0"
},
"devDependencies": {
"@types/highlight.js": "10.1.0",
......
......@@ -152,7 +152,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
}
this._register(_contributionProvider.onContributionsChanged(() => {
setImmediate(() => this.refresh());
setTimeout(() => this.refresh(), 0);
}));
this._register(vscode.workspace.onDidChangeTextDocument(event => {
......
......@@ -182,7 +182,7 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -156,7 +156,7 @@
}
},
"dependencies": {
"vscode-nls": "^4.0.0"
"vscode-nls": "^5.0.0"
},
"devDependencies": {
"@types/node": "14.x"
......
......@@ -7,7 +7,7 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.43.tgz#26bcbb0595b305400e8ceaf9a127a7f905ae49c8"
integrity sha512-3pwDJjp1PWacPTpH0LcfhgjvurQvrZFBrC6xxjaUEZ7ifUtT32jtjPxEMMblpqd2Mvx+k8haqQJLQxolyGN/cQ==
vscode-nls@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -7,7 +7,6 @@
'use strict';
const path = require('path');
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
......
......@@ -60,7 +60,7 @@
"stream": "0.0.2",
"uuid": "^8.2.0",
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.1.1"
"vscode-nls": "^5.0.0"
},
"repository": {
"type": "git",
......
......@@ -229,7 +229,7 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -9,7 +9,7 @@
const withBrowserDefaults = require('../shared.webpack.config').browser;
module.exports = withBrowserDefaults({
const config = withBrowserDefaults({
context: __dirname,
entry: {
extension: './src/npmBrowserMain.ts'
......@@ -17,8 +17,11 @@ module.exports = withBrowserDefaults({
output: {
filename: 'npmBrowserMain.js'
},
node: {
'child_process': 'empty',
'which': 'empty'
resolve: {
fallback: {
'child_process': false
}
}
});
module.exports = config;
......@@ -7,8 +7,6 @@
'use strict';
const path = require('path');
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
......
......@@ -22,8 +22,8 @@
"find-yarn-workspace-root": "^2.0.0",
"jsonc-parser": "^2.2.1",
"minimatch": "^3.0.4",
"request-light": "^0.4.0",
"vscode-nls": "^4.1.1",
"request-light": "^0.5.3",
"vscode-nls": "^5.0.0",
"which": "^2.0.2",
"which-pm": "^2.0.0"
},
......
......@@ -63,7 +63,7 @@ export class BowerJSONContribution implements IJSONContribution {
return this.xhr({
url: queryUrl,
agent: USER_AGENT
headers: { agent: USER_AGENT }
}).then((success) => {
if (success.status === 200) {
try {
......@@ -165,7 +165,7 @@ export class BowerJSONContribution implements IJSONContribution {
return this.xhr({
url: queryUrl,
agent: USER_AGENT
headers: { agent: USER_AGENT }
}).then((success) => {
try {
const obj = JSON.parse(success.responseText);
......
......@@ -96,7 +96,7 @@ export class PackageJSONContribution implements IJSONContribution {
queryUrl = `https://registry.npmjs.org/-/v1/search?size=${LIMIT}&text=${encodeURIComponent(currentWord)}`;
return this.xhr({
url: queryUrl,
agent: USER_AGENT
headers: { agent: USER_AGENT }
}).then((success) => {
if (success.status === 200) {
try {
......@@ -156,7 +156,7 @@ export class PackageJSONContribution implements IJSONContribution {
let queryUrl = `https://registry.npmjs.com/-/v1/search?text=scope:${scope}%20${name}&size=250`;
return this.xhr({
url: queryUrl,
agent: USER_AGENT
headers: { agent: USER_AGENT }
}).then((success) => {
if (success.status === 200) {
try {
......@@ -311,7 +311,7 @@ export class PackageJSONContribution implements IJSONContribution {
try {
const success = await this.xhr({
url: queryUrl,
agent: USER_AGENT
headers: { agent: USER_AGENT }
});
const obj = JSON.parse(success.responseText);
return {
......
......@@ -17,20 +17,6 @@
resolved "https://registry.yarnpkg.com/@types/which/-/which-2.0.0.tgz#446d35586611dee657120de8e0457382a658fc25"
integrity sha512-JHTNOEpZnACQdsTojWggn+SQ8IucfqEhtz7g8Z0G67WdSj4x3F0X5I2c/CVcl8z/QukGrIHeQ/N49v1au74XFQ==
agent-base@4:
version "4.2.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.2.0.tgz#9838b5c3392b962bad031e6a4c5e1024abec45ce"
integrity sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==
dependencies:
es6-promisify "^5.0.0"
agent-base@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-4.3.0.tgz#8165f01c436009bccad0b1d122f05ed770efc6ee"
integrity sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==
dependencies:
es6-promisify "^5.0.0"
argparse@1.0.9, argparse@^1.0.7:
version "1.0.9"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.9.tgz#73d83bc263f86e97f8cc4f6bae1b0e90a7d22c86"
......@@ -63,25 +49,6 @@ concat-map@0.0.1:
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=
debug@3.1.0, debug@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"
es6-promise@^4.0.3:
version "4.2.4"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
integrity sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
integrity sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=
dependencies:
es6-promise "^4.0.3"
esprima@^4.0.0:
version "4.0.1"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71"
......@@ -114,22 +81,6 @@ graceful-fs@^4.1.5:
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
http-proxy-agent@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz#e4821beef5b2142a2026bd73926fe537631c5405"
integrity sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==
dependencies:
agent-base "4"
debug "3.1.0"
https-proxy-agent@^2.2.4:
version "2.2.4"
resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz#4ee7a737abd92678a293d9b34a1af4d0d08c787b"
integrity sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==
dependencies:
agent-base "^4.3.0"
debug "^3.1.0"
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
......@@ -185,11 +136,6 @@ minimatch@^3.0.4:
dependencies:
brace-expansion "^1.1.7"
ms@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=
p-limit@^2.2.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
......@@ -224,14 +170,10 @@ pify@^4.0.1:
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
request-light@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.4.0.tgz#c6b91ef00b18cb0de75d2127e55b3a2c9f7f90f9"
integrity sha512-fimzjIVw506FBZLspTAXHdpvgvQebyjpNyLRd0e6drPPRq7gcrROeGWRyF81wLqFg5ijPgnOQbmfck5wdTqpSA==
dependencies:
http-proxy-agent "^2.1.0"
https-proxy-agent "^2.2.4"
vscode-nls "^4.1.2"
request-light@^0.5.3:
version "0.5.3"
resolved "https://registry.yarnpkg.com/request-light/-/request-light-0.5.3.tgz#bc5b103b939cde7c0653fff8ab4f43440779a5fb"
integrity sha512-wlHI5WbSZ2PcoLW2qE616PKDFCFJWaJjgRg2VaNXF9pa8MJ7+dKveJzw2HhJF8Et5uOmh9nAUJUX4iFI3Mvm/g==
sprintf-js@~1.0.2:
version "1.0.3"
......@@ -250,15 +192,10 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"
vscode-nls@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.1.tgz#f9916b64e4947b20322defb1e676a495861f133c"
integrity sha512-4R+2UoUUU/LdnMnFjePxfLqNhBS8lrAFyX7pjb2ud/lqDkrUavFUTcG7wR0HBZFakae0Q6KLBFjMS6W93F403A==
vscode-nls@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
which-pm@^2.0.0:
version "2.0.0"
......
......@@ -64,7 +64,7 @@
"body": [
"* @param ${1:Type} ${2:var} ${3:Description}$0"
],
"description": "Paramater documentation"
"description": "Parameter documentation"
},
"function …": {
"prefix": "fun",
......
......@@ -16,12 +16,6 @@ const { NLSBundlePlugin } = require('vscode-nls-dev/lib/webpack-bundler');
const { DefinePlugin } = require('webpack');
function withNodeDefaults(/**@type WebpackConfig*/extConfig) {
// Need to find the top-most `package.json` file
const folderName = path.relative(__dirname, extConfig.context).split(/[\\\/]/)[0];
const pkgPath = path.join(__dirname, folderName, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const id = `${pkg.publisher}.${pkg.name}`;
/** @type WebpackConfig */
let defaultConfig = {
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
......@@ -70,19 +64,28 @@ function withNodeDefaults(/**@type WebpackConfig*/extConfig) {
},
// yes, really source maps
devtool: 'source-map',
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
]
}),
new NLSBundlePlugin(id)
],
plugins: nodePlugins(extConfig.context),
};
return merge(defaultConfig, extConfig);
}
function nodePlugins(context) {
// Need to find the top-most `package.json` file
const folderName = path.relative(__dirname, context).split(/[\\\/]/)[0];
const pkgPath = path.join(__dirname, folderName, 'package.json');
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
const id = `${pkg.publisher}.${pkg.name}`;
return [
new CopyWebpackPlugin({
patterns: [
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
]
}),
new NLSBundlePlugin(id)
];
}
function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
/** @type WebpackConfig */
......@@ -93,8 +96,11 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
mainFields: ['module', 'main'],
extensions: ['.ts', '.js'], // support ts-files and js-files
alias: {
'vscode-nls': path.resolve(__dirname, '../build/polyfills/vscode-nls.js'),
'vscode-extension-telemetry': path.resolve(__dirname, '../build/polyfills/vscode-extension-telemetry.js')
},
fallback: {
'path': require.resolve('path-browserify'),
'util': require.resolve('util')
}
},
module: {
......@@ -130,21 +136,30 @@ function withBrowserDefaults(/**@type WebpackConfig*/extConfig) {
},
// yes, really source maps
devtool: 'source-map',
plugins: [
new CopyWebpackPlugin({
patterns: [
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
]
}),
new DefinePlugin({ WEBWORKER: JSON.stringify(true) })
]
plugins: browserPlugins
};
return merge(defaultConfig, extConfig);
}
const browserPlugins = [
new CopyWebpackPlugin({
patterns: [
{ from: 'src', to: '.', globOptions: { ignore: ['**/test/**', '**/*.ts'] }, noErrorOnMissing: true }
]
}),
new DefinePlugin({
'process.env': JSON.stringify({}),
'process.env.BROWSER_ENV': JSON.stringify('true')
})
];
module.exports = withNodeDefaults;
module.exports.node = withNodeDefaults;
module.exports.browser = withBrowserDefaults;
module.exports.nodePlugins = nodePlugins;
module.exports.browserPlugins = browserPlugins;
......@@ -67,7 +67,7 @@
},
"dependencies": {
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.0.0"
"vscode-nls": "^5.0.0"
},
"devDependencies": {
"@types/node": "14.x",
......
......@@ -100,7 +100,7 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.0.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
{
"compilerOptions": {
"target": "es2019",
"target": "es2020",
"lib": [
"es2019"
"ES2016",
"ES2017.Object",
"ES2017.String",
"ES2017.Intl",
"ES2017.TypedArrays",
"ES2018.AsyncIterable",
"ES2018.AsyncGenerator",
"ES2018.Promise",
"ES2018.Regexp",
"ES2018.Intl",
"ES2019.Array",
"ES2019.Object",
"ES2019.String",
"ES2019.Symbol",
"ES2020.BigInt",
"ES2020.Promise",
"ES2020.String",
"ES2020.Symbol.WellKnown",
"ES2020.Intl",
"ES2021.Promise",
"ES2021.String",
"ES2021.WeakRef"
],
"module": "commonjs",
"strict": true,
......
......@@ -7,10 +7,11 @@
'use strict';
const CopyPlugin = require('copy-webpack-plugin');
const { lchmod } = require('graceful-fs');
const Terser = require('terser');
const withBrowserDefaults = require('../shared.webpack.config').browser;
const defaultConfig = require('../shared.webpack.config');
const withBrowserDefaults = defaultConfig.browser;
const browserPlugins = defaultConfig.browserPlugins;
const languages = [
'zh-tw',
......@@ -34,6 +35,8 @@ module.exports = withBrowserDefaults({
extension: './src/extension.browser.ts',
},
plugins: [
...browserPlugins, // add plugins, don't replace inherited
// @ts-ignore
new CopyPlugin({
patterns: [
......@@ -62,7 +65,7 @@ module.exports = withBrowserDefaults({
from: '../node_modules/typescript/lib/tsserver.js',
to: 'typescript/tsserver.web.js',
transform: (content) => {
return Terser.minify(content.toString()).code;
return Terser.minify(content.toString()).then(output => output.code);
},
transformPath: (targetPath) => {
......
......@@ -35,7 +35,7 @@
"semver": "5.5.1",
"typescript-vscode-sh-plugin": "^0.7.3",
"vscode-extension-telemetry": "0.1.7",
"vscode-nls": "^4.1.1"
"vscode-nls": "^5.0.0"
},
"devDependencies": {
"@types/node": "14.x",
......
......@@ -8,7 +8,7 @@ import type * as Proto from '../protocol';
import { ITypeScriptServiceClient, ClientCapability } from '../typescriptService';
import API from '../utils/api';
import { coalesce } from '../utils/arrays';
import { Delayer } from '../utils/async';
import { Delayer, setImmediate } from '../utils/async';
import { nulToken } from '../utils/cancellation';
import { Disposable } from '../utils/dispose';
import * as languageModeIds from '../utils/languageModeIds';
......
......@@ -6,6 +6,7 @@
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { TypeScriptServiceConfiguration } from '../utils/configuration';
import { setImmediate } from '../utils/async';
import { Disposable } from '../utils/dispose';
import { ITypeScriptVersionProvider, TypeScriptVersion } from './versionProvider';
......
......@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable } from 'vscode';
export interface ITask<T> {
(): T;
}
......@@ -60,3 +62,13 @@ export class Delayer<T> {
}
}
}
export function setImmediate(callback: (...args: any[]) => void, ...args: any[]): Disposable {
if (global.setImmediate) {
const handle = global.setImmediate(callback, ...args);
return { dispose: () => global.clearImmediate(handle) };
} else {
const handle = setTimeout(callback, 0, ...args);
return { dispose: () => clearTimeout(handle) };
}
}
......@@ -110,7 +110,7 @@ vscode-extension-telemetry@0.1.7:
dependencies:
applicationinsights "1.7.4"
vscode-nls@^4.1.1:
version "4.1.2"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.1.2.tgz#ca8bf8bb82a0987b32801f9fddfdd2fb9fd3c167"
integrity sha512-7bOHxPsfyuCqmP+hZXscLhiHwe7CSuFE4hyhbs22xPIhQ4jv99FcR4eBzfYYVLP356HNFpdvz63FFb/xw6T4Iw==
vscode-nls@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.0.0.tgz#99f0da0bd9ea7cda44e565a74c54b1f2bc257840"
integrity sha512-u0Lw+IYlgbEJFF6/qAqG2d1jQmJl0eyAGJHoAJqr2HT4M2BNuQYSEiSE75f52pXHSJm8AlTjnLLbBFPrdz2hpA==
......@@ -676,12 +676,14 @@ import { assertNoRpc } from '../utils';
'b1~b2~',
'~c2~c1'
];
let data = '';
disposables.push(window.onDidWriteTerminalData(e => {
if (terminal !== e.terminal) {
return;
}
data += sanitizeData(e.data);
// Multiple expected could show up in the same data event
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
expectedText.shift();
// Check if all string are found, if so finish the test
if (expectedText.length === 0) {
......@@ -719,12 +721,14 @@ import { assertNoRpc } from '../utils';
'~b2~',
'~c2~'
];
let data = '';
disposables.push(window.onDidWriteTerminalData(e => {
if (terminal !== e.terminal) {
return;
}
data += sanitizeData(e.data);
// Multiple expected could show up in the same data event
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
expectedText.shift();
// Check if all string are found, if so finish the test
if (expectedText.length === 0) {
......@@ -761,12 +765,14 @@ import { assertNoRpc } from '../utils';
'~a1~',
'~b1~'
];
let data = '';
disposables.push(window.onDidWriteTerminalData(e => {
if (terminal !== e.terminal) {
return;
}
data += sanitizeData(e.data);
// Multiple expected could show up in the same data event
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
expectedText.shift();
// Check if all string are found, if so finish the test
if (expectedText.length === 0) {
......@@ -800,12 +806,14 @@ import { assertNoRpc } from '../utils';
'~a1~',
'~b2~'
];
let data = '';
disposables.push(window.onDidWriteTerminalData(e => {
if (terminal !== e.terminal) {
return;
}
data += sanitizeData(e.data);
// Multiple expected could show up in the same data event
while (expectedText.length > 0 && e.data.indexOf(expectedText[0]) >= 0) {
while (expectedText.length > 0 && data.indexOf(expectedText[0]) >= 0) {
expectedText.shift();
// Check if all string are found, if so finish the test
if (expectedText.length === 0) {
......@@ -857,3 +865,15 @@ import { assertNoRpc } from '../utils';
});
});
});
function sanitizeData(data: string): string {
// Strip NL/CR so terminal dimensions don't impact tests
data = data.replaceAll(/[\r\n]/g, '');
// Strip escape sequences so winpty/conpty doesn't cause flakiness, do for all platforms for
// consistency
const terminalCodesRegex = /(?:\u001B|\u009B)[\[\]()#;?]*(?:(?:(?:[a-zA-Z0-9]*(?:;[a-zA-Z0-9]*)*)?\u0007)|(?:(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-PR-TZcf-ntqry=><~]))/g;
data = data.replaceAll(terminalCodesRegex, '');
return data;
}
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { window, tasks, Disposable, TaskDefinition, Task, EventEmitter, CustomExecution, Pseudoterminal, TaskScope, commands, env, UIKind, ShellExecution, TaskExecution, Terminal, Event, workspace, ConfigurationTarget, TaskProcessStartEvent } from 'vscode';
import { window, tasks, Disposable, TaskDefinition, Task, Task2, EventEmitter, CustomExecution, Pseudoterminal, TaskScope, commands, env, UIKind, ShellExecution, TaskExecution, Terminal, Event, workspace, ConfigurationTarget, TaskProcessStartEvent } from 'vscode';
import { assertNoRpc } from '../utils';
// Disable tasks tests:
......@@ -331,6 +331,38 @@ import { assertNoRpc } from '../utils';
}
});
});
test('A task can be fetched with default task group information', () => {
return new Promise<void>(async (resolve, reject) => {
// Add default to tasks.json since this is not possible using an API yet.
const tasksConfig = workspace.getConfiguration('tasks');
await tasksConfig.update('version', '2.0.0', ConfigurationTarget.Workspace);
await tasksConfig.update('tasks', [
{
label: 'Run this task',
type: 'shell',
command: 'sleep 1',
problemMatcher: [],
group: {
kind: 'build',
isDefault: 'true'
}
}
], ConfigurationTarget.Workspace);
const task = <Task2[]>(await tasks.fetchTasks());
if (task && task.length > 0) {
const grp = task[0].group;
assert.strictEqual(grp?.isDefault, true);
resolve();
} else {
reject('fetched task can\'t be undefined');
}
// Reset tasks.json
await tasksConfig.update('tasks', []);
});
});
});
});
});
......@@ -62,6 +62,11 @@
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced"
},
"[dockercompose]": {
"editor.insertSpaces": true,
"editor.tabSize": 2,
"editor.autoIndent": "advanced"
}
}
},
......
{
"name": "code-oss-dev",
"version": "1.59.0",
"distro": "b10247fd6dfcf2e8ff7fb4772bc58a2e97e108a3",
"distro": "ed2fca765acb42a6c17b1d023464f0c69077ca1b",
"author": {
"name": "Microsoft Corporation"
},
......@@ -127,7 +127,7 @@
"cssnano": "^4.1.11",
"debounce": "^1.0.0",
"deemon": "^1.4.0",
"electron": "12.0.13",
"electron": "13.1.6",
"eslint": "6.8.0",
"eslint-plugin-jsdoc": "^19.1.0",
"event-stream": "3.3.4",
......@@ -179,6 +179,7 @@
"opn": "^6.0.0",
"optimist": "0.3.5",
"p-all": "^1.0.0",
"path-browserify": "^1.0.1",
"playwright": "1.12.3",
"pump": "^1.0.1",
"queue": "3.0.6",
......@@ -190,19 +191,20 @@
"source-map": "0.6.1",
"source-map-support": "^0.3.2",
"style-loader": "^1.0.0",
"ts-loader": "^6.2.1",
"ts-loader": "^9.2.3",
"tsec": "0.1.4",
"typescript": "^4.4.0-dev.20210708",
"util": "^0.12.4",
"typescript": "^4.4.0-dev.20210713",
"typescript-formatter": "7.1.0",
"underscore": "^1.12.1",
"vinyl": "^2.0.0",
"vinyl-fs": "^3.0.0",
"vscode-debugprotocol": "1.47.0",
"vscode-debugprotocol": "1.48.0-pre.0",
"vscode-nls-dev": "^3.3.1",
"vscode-telemetry-extractor": "^1.8.0",
"webpack": "^4.43.0",
"webpack-cli": "^3.3.12",
"webpack-stream": "^5.2.1",
"webpack": "^5.42.0",
"webpack-cli": "^4.7.2",
"webpack-stream": "^6.1.2",
"xml2js": "^0.4.17",
"yaserver": "^0.2.0"
},
......@@ -223,4 +225,4 @@
"elliptic": "^6.5.3",
"nwmatcher": "^1.4.4"
}
}
\ No newline at end of file
}
......@@ -48,7 +48,18 @@ const argvConfig = configureCommandlineSwitchesSync(args);
// Configure crash reporter
perf.mark('code/willStartCrashReporter');
configureCrashReporter();
// If a crash-reporter-directory is specified we store the crash reports
// in the specified directory and don't upload them to the crash server.
//
// Appcenter crash reporting is enabled if
// * enable-crash-reporter runtime argument is set to 'true'
// * --disable-crash-reporter command line parameter is not set
//
// Disable crash reporting in all other cases.
if (args['crash-reporter-directory'] ||
(argvConfig['enable-crash-reporter'] && !args['disable-crash-reporter'])) {
configureCrashReporter();
}
perf.mark('code/didStartCrashReporter');
// Set logs path before app 'ready' event if running portable
......@@ -321,8 +332,6 @@ function getArgvConfigPath() {
function configureCrashReporter() {
// If a crash-reporter-directory is specified we store the crash reports
// in the specified directory and don't upload them to the crash server.
let crashReporterDirectory = args['crash-reporter-directory'];
let submitURL = '';
if (crashReporterDirectory) {
......@@ -351,11 +360,7 @@ function configureCrashReporter() {
// Otherwise we configure the crash reporter from product.json
else {
const appCenter = product.appCenter;
// Disable Appcenter crash reporting if
// * --crash-reporter-directory is specified
// * enable-crash-reporter runtime argument is set to 'false'
// * --disable-crash-reporter command line parameter is set
if (appCenter && argvConfig['enable-crash-reporter'] && !args['disable-crash-reporter']) {
if (appCenter) {
const isWindows = (process.platform === 'win32');
const isLinux = (process.platform === 'linux');
const isDarwin = (process.platform === 'darwin');
......@@ -410,13 +415,23 @@ function configureCrashReporter() {
// Start crash reporter for all processes
const productName = (product.crashReporter ? product.crashReporter.productName : undefined) || product.nameShort;
const companyName = (product.crashReporter ? product.crashReporter.companyName : undefined) || 'Microsoft';
crashReporter.start({
companyName: companyName,
productName: process.env['VSCODE_DEV'] ? `${productName} Dev` : productName,
submitURL,
uploadToServer: !crashReporterDirectory,
compress: true
});
if (process.env['VSCODE_DEV']) {
crashReporter.start({
companyName: companyName,
productName: `${productName} Dev`,
submitURL,
uploadToServer: false,
compress: true
});
} else {
crashReporter.start({
companyName: companyName,
productName: productName,
submitURL,
uploadToServer: !crashReporterDirectory,
compress: true
});
}
}
/**
......
......@@ -39,7 +39,7 @@
"ES2020.Intl",
"ES2021.Promise",
"ES2021.String",
"ES2021.Weakref",
"ES2021.WeakRef",
"DOM",
"DOM.Iterable",
"WebWorker.ImportScripts"
......
......@@ -35,7 +35,7 @@
padding-left: 0px;
padding-right: 0px;
line-height: 16px;
margin-left: -4px;
margin-left: -3px;
}
.monaco-dropdown-with-primary > .dropdown-action-container > .monaco-dropdown > .dropdown-label > .action-label {
......
......@@ -311,6 +311,27 @@ export class MutableDisposable<T extends IDisposable> implements IDisposable {
}
}
export class RefCountedDisposable {
private _counter: number = 1;
constructor(
private readonly _disposable: IDisposable,
) { }
acquire() {
this._counter++;
return this;
}
release() {
if (--this._counter === 0) {
this._disposable.dispose();
}
return this;
}
}
export interface IReference<T> extends IDisposable {
readonly object: T;
}
......
......@@ -287,6 +287,6 @@ export function NotImplementedProxy<T>(name: string): { new(): T } {
};
}
export function assertNever(value: never) {
throw new Error('Unreachable');
export function assertNever(value: never, message = 'Unreachable') {
throw new Error(message);
}
......@@ -342,18 +342,13 @@
// Use `contextBridge` APIs to expose globals to VSCode
// only if context isolation is enabled, otherwise just
// add to the DOM global.
let useContextBridge = process.argv.includes('--context-isolation');
if (useContextBridge) {
if (process.contextIsolated) {
try {
contextBridge.exposeInMainWorld('vscode', globals);
} catch (error) {
console.error(error);
useContextBridge = false;
}
}
if (!useContextBridge) {
} else {
// @ts-ignore
window.vscode = globals;
}
......
......@@ -124,11 +124,16 @@ export class CodeApplication extends Disposable {
// !!! DO NOT CHANGE without consulting the documentation !!!
//
const isUrlFromWebview = (requestingUrl: string) => requestingUrl.startsWith(`${Schemas.vscodeWebview}://`);
const isUrlFromWebview = (requestingUrl: string | undefined) => requestingUrl?.startsWith(`${Schemas.vscodeWebview}://`);
const allowedPermissionsInWebview = new Set([
'clipboard-read',
'clipboard-sanitized-write',
]);
session.defaultSession.setPermissionRequestHandler((_webContents, permission /* 'media' | 'geolocation' | 'notifications' | 'midiSysex' | 'pointerLock' | 'fullscreen' | 'openExternal' */, callback, details) => {
if (isUrlFromWebview(details.requestingUrl)) {
return callback(permission === 'clipboard-read');
return callback(allowedPermissionsInWebview.has(permission));
}
return callback(false);
......@@ -136,7 +141,7 @@ export class CodeApplication extends Disposable {
session.defaultSession.setPermissionCheckHandler((_webContents, permission /* 'media' */, _origin, details) => {
if (isUrlFromWebview(details.requestingUrl)) {
return permission === 'clipboard-read';
return allowedPermissionsInWebview.has(permission);
}
return false;
......
......@@ -10,7 +10,7 @@ import { URI } from 'vs/base/common/uri';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { AbstractCodeEditorService } from 'vs/editor/browser/services/abstractCodeEditorService';
import { IContentDecorationRenderOptions, IDecorationRenderOptions, IThemeDecorationRenderOptions, isThemeColor } from 'vs/editor/common/editorCommon';
import { IModelDecorationOptions, IModelDecorationOverviewRulerOptions, OverviewRulerLane, TrackedRangeStickiness } from 'vs/editor/common/model';
import { IModelDecorationOptions, IModelDecorationOverviewRulerOptions, InjectedTextOptions, OverviewRulerLane, TrackedRangeStickiness } from 'vs/editor/common/model';
import { IColorTheme, IThemeService, ThemeColor } from 'vs/platform/theme/common/themeService';
export class RefCountedStyleSheet {
......@@ -250,6 +250,8 @@ export class DecorationTypeOptionsProvider implements IModelDecorationOptionsPro
public isWholeLine: boolean;
public overviewRuler: IModelDecorationOverviewRulerOptions | undefined;
public stickiness: TrackedRangeStickiness | undefined;
public beforeInjectedText: InjectedTextOptions | undefined;
public afterInjectedText: InjectedTextOptions | undefined;
constructor(description: string, themeService: IThemeService, styleSheet: GlobalStyleSheet | RefCountedStyleSheet, providerArgs: ProviderArguments) {
this.description = description;
......@@ -283,6 +285,25 @@ export class DecorationTypeOptionsProvider implements IModelDecorationOptionsPro
}
this.beforeContentClassName = createCSSRules(ModelDecorationCSSRuleType.BeforeContentClassName);
this.afterContentClassName = createCSSRules(ModelDecorationCSSRuleType.AfterContentClassName);
if (providerArgs.options.beforeInjectedText && providerArgs.options.beforeInjectedText.contentText) {
const beforeInlineData = createInlineCSSRules(ModelDecorationCSSRuleType.BeforeInjectedTextClassName);
this.beforeInjectedText = {
content: providerArgs.options.beforeInjectedText.contentText,
inlineClassName: beforeInlineData?.className,
inlineClassNameAffectsLetterSpacing: beforeInlineData?.hasLetterSpacing || providerArgs.options.beforeInjectedText.affectsLetterSpacing
};
}
if (providerArgs.options.afterInjectedText && providerArgs.options.afterInjectedText.contentText) {
const afterInlineData = createInlineCSSRules(ModelDecorationCSSRuleType.AfterInjectedTextClassName);
this.afterInjectedText = {
content: providerArgs.options.afterInjectedText.contentText,
inlineClassName: afterInlineData?.className,
inlineClassNameAffectsLetterSpacing: afterInlineData?.hasLetterSpacing || providerArgs.options.afterInjectedText.affectsLetterSpacing
};
}
this.glyphMarginClassName = createCSSRules(ModelDecorationCSSRuleType.GlyphMarginClassName);
const options = providerArgs.options;
......@@ -307,6 +328,7 @@ export class DecorationTypeOptionsProvider implements IModelDecorationOptionsPro
if (!writable) {
return this;
}
return {
description: this.description,
inlineClassName: this.inlineClassName,
......@@ -316,7 +338,8 @@ export class DecorationTypeOptionsProvider implements IModelDecorationOptionsPro
glyphMarginClassName: this.glyphMarginClassName,
isWholeLine: this.isWholeLine,
overviewRuler: this.overviewRuler,
stickiness: this.stickiness
stickiness: this.stickiness,
before: this.beforeInjectedText
};
}
......@@ -461,6 +484,16 @@ class DecorationCSSRules {
lightCSS = this.getCSSTextForModelDecorationContentClassName(options.light && options.light.after);
darkCSS = this.getCSSTextForModelDecorationContentClassName(options.dark && options.dark.after);
break;
case ModelDecorationCSSRuleType.BeforeInjectedTextClassName:
unthemedCSS = this.getCSSTextForModelDecorationContentClassName(options.beforeInjectedText);
lightCSS = this.getCSSTextForModelDecorationContentClassName(options.light && options.light.beforeInjectedText);
darkCSS = this.getCSSTextForModelDecorationContentClassName(options.dark && options.dark.beforeInjectedText);
break;
case ModelDecorationCSSRuleType.AfterInjectedTextClassName:
unthemedCSS = this.getCSSTextForModelDecorationContentClassName(options.afterInjectedText);
lightCSS = this.getCSSTextForModelDecorationContentClassName(options.light && options.light.afterInjectedText);
darkCSS = this.getCSSTextForModelDecorationContentClassName(options.dark && options.dark.afterInjectedText);
break;
default:
throw new Error('Unknown rule type: ' + this._ruleType);
}
......@@ -600,7 +633,9 @@ const enum ModelDecorationCSSRuleType {
InlineClassName = 1,
GlyphMarginClassName = 2,
BeforeContentClassName = 3,
AfterContentClassName = 4
AfterContentClassName = 4,
BeforeInjectedTextClassName = 5,
AfterInjectedTextClassName = 6,
}
class CSSNameHelper {
......
......@@ -620,6 +620,9 @@ export interface IThemeDecorationRenderOptions {
before?: IContentDecorationRenderOptions;
after?: IContentDecorationRenderOptions;
beforeInjectedText?: IContentDecorationRenderOptions & { affectsLetterSpacing?: boolean };
afterInjectedText?: IContentDecorationRenderOptions & { affectsLetterSpacing?: boolean };
}
/**
......
......@@ -118,12 +118,12 @@ export class CoordinatesConverter implements ICoordinatesConverter {
// Model -> View conversion and related methods
public convertModelPositionToViewPosition(modelPosition: Position): Position {
return this._lines.convertModelPositionToViewPosition(modelPosition.lineNumber, modelPosition.column);
public convertModelPositionToViewPosition(modelPosition: Position, affinity?: PositionAffinity): Position {
return this._lines.convertModelPositionToViewPosition(modelPosition.lineNumber, modelPosition.column, affinity);
}
public convertModelRangeToViewRange(modelRange: Range): Range {
return this._lines.convertModelRangeToViewRange(modelRange);
public convertModelRangeToViewRange(modelRange: Range, affinity?: PositionAffinity): Range {
return this._lines.convertModelRangeToViewRange(modelRange, affinity);
}
public modelPositionIsVisible(modelPosition: Position): boolean {
......@@ -886,9 +886,12 @@ export class SplitLinesCollection implements IViewModelLinesCollection {
return r;
}
public convertModelRangeToViewRange(modelRange: Range): Range {
/**
* @param affinity The affinity in case of an empty range. Has no effect for non-empty ranges.
*/
public convertModelRangeToViewRange(modelRange: Range, affinity: PositionAffinity = PositionAffinity.Left): Range {
if (modelRange.isEmpty()) {
const start = this.convertModelPositionToViewPosition(modelRange.startLineNumber, modelRange.startColumn, PositionAffinity.Left);
const start = this.convertModelPositionToViewPosition(modelRange.startLineNumber, modelRange.startColumn, affinity);
return Range.fromPositions(start);
} else {
const start = this.convertModelPositionToViewPosition(modelRange.startLineNumber, modelRange.startColumn, PositionAffinity.Right);
......
......@@ -82,8 +82,11 @@ export interface ICoordinatesConverter {
validateViewRange(viewRange: Range, expectedModelRange: Range): Range;
// Model -> View conversion and related methods
convertModelPositionToViewPosition(modelPosition: Position): Position;
convertModelRangeToViewRange(modelRange: Range): Range;
convertModelPositionToViewPosition(modelPosition: Position, affinity?: PositionAffinity): Position;
/**
* @param affinity Only has an effect if the range is empty.
*/
convertModelRangeToViewRange(modelRange: Range, affinity?: PositionAffinity): Range;
modelPositionIsVisible(modelPosition: Position): boolean;
getModelLineViewLineCount(modelLineNumber: number): number;
}
......
......@@ -7,7 +7,7 @@ import { IDisposable } from 'vs/base/common/lifecycle';
import { Position } from 'vs/editor/common/core/position';
import { Range } from 'vs/editor/common/core/range';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { IModelDecoration, ITextModel } from 'vs/editor/common/model';
import { IModelDecoration, ITextModel, PositionAffinity } from 'vs/editor/common/model';
import { IViewModelLinesCollection } from 'vs/editor/common/viewModel/splitLinesCollection';
import { ICoordinatesConverter, InlineDecoration, InlineDecorationType, ViewModelDecoration } from 'vs/editor/common/viewModel/viewModel';
import { filterValidationDecorations } from 'vs/editor/common/config/editorOptions';
......@@ -81,11 +81,13 @@ export class ViewModelDecorations implements IDisposable {
const options = modelDecoration.options;
let viewRange: Range;
if (options.isWholeLine) {
const start = this._coordinatesConverter.convertModelPositionToViewPosition(new Position(modelRange.startLineNumber, 1));
const end = this._coordinatesConverter.convertModelPositionToViewPosition(new Position(modelRange.endLineNumber, this.model.getLineMaxColumn(modelRange.endLineNumber)));
const start = this._coordinatesConverter.convertModelPositionToViewPosition(new Position(modelRange.startLineNumber, 1), PositionAffinity.Left);
const end = this._coordinatesConverter.convertModelPositionToViewPosition(new Position(modelRange.endLineNumber, this.model.getLineMaxColumn(modelRange.endLineNumber)), PositionAffinity.Right);
viewRange = new Range(start.lineNumber, start.column, end.lineNumber, end.column);
} else {
viewRange = this._coordinatesConverter.convertModelRangeToViewRange(modelRange);
// For backwards compatibility reasons, we want injected text before any decoration.
// Thus, move decorations to the right.
viewRange = this._coordinatesConverter.convertModelRangeToViewRange(modelRange, PositionAffinity.Right);
}
r = new ViewModelDecoration(viewRange, options);
this._decorationsCache[id] = r;
......
......@@ -26,6 +26,7 @@ import { IRange } from 'vs/base/common/range';
import { assertType } from 'vs/base/common/types';
import { ITextModelService } from 'vs/editor/common/services/resolverService';
import { Position } from 'vs/editor/common/core/position';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
const MAX_DECORATORS = 500;
......@@ -56,7 +57,7 @@ export class InlayHintsController implements IEditorContribution {
private readonly _disposables = new DisposableStore();
private readonly _sessionDisposables = new DisposableStore();
private readonly _getInlayHintsDelays = new LanguageFeatureRequestDelays(InlayHintsProviderRegistry, 250, 2500);
private readonly _getInlayHintsDelays = new LanguageFeatureRequestDelays(InlayHintsProviderRegistry, 25, 2500);
private _decorationsTypeIds: string[] = [];
private _decorationIds: string[] = [];
......@@ -65,6 +66,7 @@ export class InlayHintsController implements IEditorContribution {
private readonly _editor: ICodeEditor,
@ICodeEditorService private readonly _codeEditorService: ICodeEditorService,
@IThemeService private readonly _themeService: IThemeService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
) {
this._disposables.add(InlayHintsProviderRegistry.onDidChange(() => this._update()));
this._disposables.add(_themeService.onDidColorThemeChange(() => this._update()));
......@@ -145,6 +147,9 @@ export class InlayHintsController implements IEditorContribution {
const fontFamilyVar = '--inlayHintsFontFamily';
this._editor.getContainerDomNode().style.setProperty(fontFamilyVar, fontFamily);
const key = this._configurationService.getValue('editor.useInjectedText');
const shouldUseInjectedText = key === undefined ? true : !!key;
for (const { list: hints } of hintsData) {
for (let j = 0; j < hints.length && newDecorationsData.length < MAX_DECORATORS; j++) {
......@@ -163,7 +168,8 @@ export class InlayHintsController implements IEditorContribution {
borderRadius: `${(fontSize / 4) | 0}px`,
};
const key = 'inlayHints-' + hash(before).toString(16);
this._codeEditorService.registerDecorationType('inlay-hints-controller', key, { before }, undefined, this._editor);
this._codeEditorService.registerDecorationType('inlay-hints-controller', key,
shouldUseInjectedText ? { beforeInjectedText: { ...before, affectsLetterSpacing: true } } : { before }, undefined, this._editor);
// decoration types are ref-counted which means we only need to
// call register und remove equally often
......
......@@ -79,7 +79,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
}));
}
private createParamaterHintDOMNodes() {
private createParameterHintDOMNodes() {
const element = $('.editor-widget.parameter-hints-widget');
const wrapper = dom.append(element, $('.phwrapper'));
wrapper.tabIndex = -1;
......@@ -150,7 +150,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
}
if (!this.domNodes) {
this.createParamaterHintDOMNodes();
this.createParameterHintDOMNodes();
}
this.keyVisible.set(true);
......@@ -352,7 +352,7 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
getDomNode(): HTMLElement {
if (!this.domNodes) {
this.createParamaterHintDOMNodes();
this.createParameterHintDOMNodes();
}
return this.domNodes!.element;
}
......
......@@ -255,33 +255,37 @@ export class TimeBasedVariableResolver implements VariableResolver {
private static readonly monthNames = [nls.localize('January', "January"), nls.localize('February', "February"), nls.localize('March', "March"), nls.localize('April', "April"), nls.localize('May', "May"), nls.localize('June', "June"), nls.localize('July', "July"), nls.localize('August', "August"), nls.localize('September', "September"), nls.localize('October', "October"), nls.localize('November', "November"), nls.localize('December', "December")];
private static readonly monthNamesShort = [nls.localize('JanuaryShort', "Jan"), nls.localize('FebruaryShort', "Feb"), nls.localize('MarchShort', "Mar"), nls.localize('AprilShort', "Apr"), nls.localize('MayShort', "May"), nls.localize('JuneShort', "Jun"), nls.localize('JulyShort', "Jul"), nls.localize('AugustShort', "Aug"), nls.localize('SeptemberShort', "Sep"), nls.localize('OctoberShort', "Oct"), nls.localize('NovemberShort', "Nov"), nls.localize('DecemberShort', "Dec")];
constructor(private readonly _date: Date = new Date()) {
//
}
resolve(variable: Variable): string | undefined {
const { name } = variable;
if (name === 'CURRENT_YEAR') {
return String(new Date().getFullYear());
return String(this._date.getFullYear());
} else if (name === 'CURRENT_YEAR_SHORT') {
return String(new Date().getFullYear()).slice(-2);
return String(this._date.getFullYear()).slice(-2);
} else if (name === 'CURRENT_MONTH') {
return String(new Date().getMonth().valueOf() + 1).padStart(2, '0');
return String(this._date.getMonth().valueOf() + 1).padStart(2, '0');
} else if (name === 'CURRENT_DATE') {
return String(new Date().getDate().valueOf()).padStart(2, '0');
return String(this._date.getDate().valueOf()).padStart(2, '0');
} else if (name === 'CURRENT_HOUR') {
return String(new Date().getHours().valueOf()).padStart(2, '0');
return String(this._date.getHours().valueOf()).padStart(2, '0');
} else if (name === 'CURRENT_MINUTE') {
return String(new Date().getMinutes().valueOf()).padStart(2, '0');
return String(this._date.getMinutes().valueOf()).padStart(2, '0');
} else if (name === 'CURRENT_SECOND') {
return String(new Date().getSeconds().valueOf()).padStart(2, '0');
return String(this._date.getSeconds().valueOf()).padStart(2, '0');
} else if (name === 'CURRENT_DAY_NAME') {
return TimeBasedVariableResolver.dayNames[new Date().getDay()];
return TimeBasedVariableResolver.dayNames[this._date.getDay()];
} else if (name === 'CURRENT_DAY_NAME_SHORT') {
return TimeBasedVariableResolver.dayNamesShort[new Date().getDay()];
return TimeBasedVariableResolver.dayNamesShort[this._date.getDay()];
} else if (name === 'CURRENT_MONTH_NAME') {
return TimeBasedVariableResolver.monthNames[new Date().getMonth()];
return TimeBasedVariableResolver.monthNames[this._date.getMonth()];
} else if (name === 'CURRENT_MONTH_NAME_SHORT') {
return TimeBasedVariableResolver.monthNamesShort[new Date().getMonth()];
return TimeBasedVariableResolver.monthNamesShort[this._date.getMonth()];
} else if (name === 'CURRENT_SECONDS_UNIX') {
return String(Math.floor(Date.now() / 1000));
return String(Math.floor(this._date.getTime() / 1000));
}
return undefined;
......
......@@ -17,6 +17,7 @@ import { Workspace } from 'vs/platform/workspace/test/common/testWorkspace';
import { extUriBiasedIgnorePathCase } from 'vs/base/common/resources';
import { sep } from 'vs/base/common/path';
import { toWorkspaceFolders } from 'vs/platform/workspaces/common/workspaces';
import * as sinon from 'sinon';
suite('Snippet Variables Resolver', function () {
......@@ -291,6 +292,36 @@ suite('Snippet Variables Resolver', function () {
assertVariableResolve3(resolver, 'CURRENT_SECONDS_UNIX');
});
test('Time-based snippet variables resolve to the same values even as time progresses', async function () {
const snippetText = `
$CURRENT_YEAR
$CURRENT_YEAR_SHORT
$CURRENT_MONTH
$CURRENT_DATE
$CURRENT_HOUR
$CURRENT_MINUTE
$CURRENT_SECOND
$CURRENT_DAY_NAME
$CURRENT_DAY_NAME_SHORT
$CURRENT_MONTH_NAME
$CURRENT_MONTH_NAME_SHORT
$CURRENT_SECONDS_UNIX
`;
const clock = sinon.useFakeTimers();
try {
const resolver = new TimeBasedVariableResolver;
const firstResolve = new SnippetParser().parse(snippetText).resolveVariables(resolver);
clock.tick((365 * 24 * 3600 * 1000) + (24 * 3600 * 1000) + (3661 * 1000)); // 1 year + 1 day + 1 hour + 1 minute + 1 second
const secondResolve = new SnippetParser().parse(snippetText).resolveVariables(resolver);
assert.strictEqual(firstResolve.toString(), secondResolve.toString(), `Time-based snippet variables resolved differently`);
} finally {
clock.restore();
}
});
test('creating snippet - format-condition doesn\'t work #53617', function () {
const snippet = new SnippetParser().parse('${TM_LINE_NUMBER/(10)/${1:?It is:It is not}/} line 10', true);
......
......@@ -116,9 +116,6 @@ suite('ViewModelDecorations', () => {
new InlineDecoration(new Range(1, 2, 1, 2), 'b-dec4', InlineDecorationType.Before),
new InlineDecoration(new Range(1, 2, 5, 8), 'i-dec5', InlineDecorationType.Regular),
new InlineDecoration(new Range(1, 2, 1, 2), 'b-dec5', InlineDecorationType.Before),
new InlineDecoration(new Range(1, 14, 1, 14), 'i-dec6', InlineDecorationType.Regular),
new InlineDecoration(new Range(1, 14, 1, 14), 'b-dec6', InlineDecorationType.Before),
new InlineDecoration(new Range(1, 14, 1, 14), 'a-dec6', InlineDecorationType.After),
]);
const inlineDecorations2 = viewModel.getViewLineRenderingData(
......@@ -132,6 +129,9 @@ suite('ViewModelDecorations', () => {
new InlineDecoration(new Range(2, 2, 2, 2), 'a-dec3', InlineDecorationType.After),
new InlineDecoration(new Range(1, 2, 3, 13), 'i-dec4', InlineDecorationType.Regular),
new InlineDecoration(new Range(1, 2, 5, 8), 'i-dec5', InlineDecorationType.Regular),
new InlineDecoration(new Range(2, 1, 2, 1), 'i-dec6', InlineDecorationType.Regular),
new InlineDecoration(new Range(2, 1, 2, 1), 'b-dec6', InlineDecorationType.Before),
new InlineDecoration(new Range(2, 1, 2, 1), 'a-dec6', InlineDecorationType.After),
new InlineDecoration(new Range(2, 1, 2, 3), 'i-dec7', InlineDecorationType.Regular),
new InlineDecoration(new Range(2, 1, 2, 1), 'b-dec7', InlineDecorationType.Before),
new InlineDecoration(new Range(2, 3, 2, 3), 'a-dec7', InlineDecorationType.After),
......@@ -164,9 +164,6 @@ suite('ViewModelDecorations', () => {
new InlineDecoration(new Range(2, 3, 3, 13), 'i-dec11', InlineDecorationType.Regular),
new InlineDecoration(new Range(3, 13, 3, 13), 'a-dec11', InlineDecorationType.After),
new InlineDecoration(new Range(2, 3, 5, 8), 'i-dec12', InlineDecorationType.Regular),
new InlineDecoration(new Range(3, 13, 3, 13), 'i-dec13', InlineDecorationType.Regular),
new InlineDecoration(new Range(3, 13, 3, 13), 'b-dec13', InlineDecorationType.Before),
new InlineDecoration(new Range(3, 13, 3, 13), 'a-dec13', InlineDecorationType.After),
]);
});
});
......
......@@ -8,7 +8,7 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
/**
* Returns the user data path to use with some rules:
* - respect portable mode
* - respect --user-data-dir CLI argument
* - respect VSCODE_APPDATA environment variable
* - respect --user-data-dir CLI argument
*/
export function getUserDataPath(args: NativeParsedArgs): string;
......@@ -54,38 +54,42 @@
return path.join(portablePath, 'user-data');
}
// 2. Support explicit --user-data-dir
// 2. Support global VSCODE_APPDATA environment variable
let appDataPath = process.env['VSCODE_APPDATA'];
if (appDataPath) {
return path.join(appDataPath, productName);
}
// With Electron>=13 --user-data-dir switch will be propagated to
// all processes https://github.com/electron/electron/blob/1897b14af36a02e9aa7e4d814159303441548251/shell/browser/electron_browser_client.cc#L546-L553
// Check VSCODE_PORTABLE and VSCODE_APPDATA before this case to get correct values.
// 3. Support explicit --user-data-dir
const cliPath = cliArgs['user-data-dir'];
if (cliPath) {
return cliPath;
}
// 3. Support global VSCODE_APPDATA environment variable
let appDataPath = process.env['VSCODE_APPDATA'];
// 4. Otherwise check per platform
if (!appDataPath) {
switch (process.platform) {
case 'win32':
appDataPath = process.env['APPDATA'];
if (!appDataPath) {
const userProfile = process.env['USERPROFILE'];
if (typeof userProfile !== 'string') {
throw new Error('Windows: Unexpected undefined %USERPROFILE% environment variable');
}
appDataPath = path.join(userProfile, 'AppData', 'Roaming');
switch (process.platform) {
case 'win32':
appDataPath = process.env['APPDATA'];
if (!appDataPath) {
const userProfile = process.env['USERPROFILE'];
if (typeof userProfile !== 'string') {
throw new Error('Windows: Unexpected undefined %USERPROFILE% environment variable');
}
break;
case 'darwin':
appDataPath = path.join(os.homedir(), 'Library', 'Application Support');
break;
case 'linux':
appDataPath = process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config');
break;
default:
throw new Error('Platform not supported');
}
appDataPath = path.join(userProfile, 'AppData', 'Roaming');
}
break;
case 'darwin':
appDataPath = path.join(os.homedir(), 'Library', 'Application Support');
break;
case 'linux':
appDataPath = process.env['XDG_CONFIG_HOME'] || path.join(os.homedir(), '.config');
break;
default:
throw new Error('Platform not supported');
}
return path.join(appDataPath, productName);
......
......@@ -316,7 +316,7 @@ export class IssueMainService implements ICommonIssueService {
backgroundColor: options.backgroundColor || IssueMainService.DEFAULT_BACKGROUND_COLOR,
webPreferences: {
preload: FileAccess.asFileUri('vs/base/parts/sandbox/electron-browser/preload.js', require).fsPath,
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`, '--context-isolation' /* TODO@bpasero: Use process.contextIsolateed when 13-x-y is adopted (https://github.com/electron/electron/pull/28030) */],
additionalArguments: [`--vscode-window-config=${ipcObjectUrl.resource.toString()}`],
v8CacheOptions: browserCodeLoadingCacheStrategy,
enableWebSQL: false,
spellcheck: false,
......
......@@ -67,6 +67,7 @@ export const enum TerminalSettingId {
RightClickBehavior = 'terminal.integrated.rightClickBehavior',
Cwd = 'terminal.integrated.cwd',
ConfirmOnExit = 'terminal.integrated.confirmOnExit',
ConfirmOnKill = 'terminal.integrated.confirmOnKill',
EnableBell = 'terminal.integrated.enableBell',
CommandsToSkipShell = 'terminal.integrated.commandsToSkipShell',
AllowChords = 'terminal.integrated.allowChords',
......@@ -185,6 +186,8 @@ export interface IPtyService {
readonly onProcessResolvedShellLaunchConfig: Event<{ id: number, event: IShellLaunchConfig }>;
readonly onProcessReplay: Event<{ id: number, event: IPtyHostProcessReplayEvent }>;
readonly onProcessOrphanQuestion: Event<{ id: number }>;
readonly onDidRequestDetach: Event<{ requestId: number, workspaceId: string, instanceId: number }>;
readonly onProcessDidChangeHasChildProcesses: Event<{ id: number, event: boolean }>;
restartPtyHost?(): Promise<void>;
shutdownAll?(): Promise<void>;
......@@ -230,6 +233,8 @@ export interface IPtyService {
setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): Promise<void>;
getTerminalLayoutInfo(args: IGetTerminalLayoutInfoArgs): Promise<ITerminalsLayoutInfo | undefined>;
reduceConnectionGraceTime(): Promise<void>;
requestDetachInstance(workspaceId: string, instanceId: number): Promise<IProcessDetails | undefined>;
acceptDetachedInstance(requestId: number, process: number): Promise<IProcessDetails | undefined>;
}
export interface IRequestResolveVariablesEvent {
......@@ -457,9 +462,10 @@ export interface ITerminalChildProcess {
onProcessExit: Event<number | undefined>;
onProcessReady: Event<IProcessReadyEvent>;
onProcessTitleChanged: Event<string>;
onProcessShellTypeChanged: Event<TerminalShellType>;
onProcessOverrideDimensions?: Event<ITerminalDimensionsOverride | undefined>;
onProcessResolvedShellLaunchConfig?: Event<IShellLaunchConfig>;
onProcessShellTypeChanged: Event<TerminalShellType>;
onDidChangeHasChildProcesses?: Event<boolean>;
/**
* Starts the process.
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { debounce, throttle } from 'vs/base/common/decorators';
import { Disposable } from 'vs/base/common/lifecycle';
import { Emitter } from 'vs/base/common/event';
import { listProcesses } from 'vs/base/node/ps';
import { ILogService } from 'vs/platform/log/common/log';
import { ProcessItem } from 'vs/base/common/processes';
import { parse } from 'path';
const enum Constants {
/**
* The amount of time to throttle checks when the process receives output.
*/
InactiveThrottleDuration = 5000,
/**
* The amount of time to debounce check when the process receives input.
*/
ActiveDebounceDuration = 1000,
}
const ignoreProcessNames = [
// Popular prompt programs, these should not count as child processes
'starship',
'oh-my-posh'
];
/**
* Monitors a process for child processes, checking at differing times depending on input and output
* calls into the monitor.
*/
export class ChildProcessMonitor extends Disposable {
private _isDisposed: boolean = false;
private _hasChildProcesses: boolean = false;
private set hasChildProcesses(value: boolean) {
if (this._hasChildProcesses !== value) {
this._hasChildProcesses = value;
this._logService.debug('ChildProcessMonitor: Has child processes changed', value);
this._onDidChangeHasChildProcesses.fire(value);
}
}
/**
* Whether the process has child processes.
*/
get hasChildProcesses(): boolean { return this._hasChildProcesses; }
private readonly _onDidChangeHasChildProcesses = this._register(new Emitter<boolean>());
/**
* An event that fires when whether the process has child processes changes.
*/
readonly onDidChangeHasChildProcesses = this._onDidChangeHasChildProcesses.event;
constructor(
private readonly _pid: number,
@ILogService private readonly _logService: ILogService
) {
super();
}
override dispose() {
this._isDisposed = true;
super.dispose();
}
/**
* Input was triggered on the process.
*/
handleInput() {
this._refreshActive();
}
/**
* Output was triggered on the process.
*/
handleOutput() {
this._refreshInactive();
}
@debounce(Constants.ActiveDebounceDuration)
private async _refreshActive(): Promise<void> {
if (this._isDisposed) {
return;
}
try {
const processItem = await listProcesses(this._pid);
this.hasChildProcesses = this._processContainsChildren(processItem);
} catch (e) {
this._logService.debug('ChildProcessMonitor: Fetching process tree failed', e);
}
}
@throttle(Constants.InactiveThrottleDuration)
private _refreshInactive(): void {
this._refreshActive();
}
private _processContainsChildren(processItem: ProcessItem): boolean {
// No child processes
if (!processItem.children) {
return false;
}
// A single child process, handle special cases
if (processItem.children.length === 1) {
const item = processItem.children[0];
let cmd: string;
if (item.cmd.startsWith(`"`)) {
cmd = item.cmd.substring(1, item.cmd.indexOf(`"`, 1));
} else {
const spaceIndex = item.cmd.indexOf(` `);
if (spaceIndex === -1) {
cmd = item.cmd;
} else {
cmd = item.cmd.substring(0, spaceIndex);
}
}
return ignoreProcessNames.indexOf(parse(cmd).name) === -1;
}
// Fallback, count child processes
return processItem.children.length > 0;
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册