From b5ae100c721ba93e668c4e5702acfde04c20675b Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 3 Dec 2021 14:09:19 -0800 Subject: [PATCH 01/10] Fix #138427 --- .../contrib/notebook/browser/viewModel/baseCellViewModel.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts index 9c022a93c240e..fabc8219d807d 100644 --- a/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts +++ b/src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts @@ -104,10 +104,8 @@ export abstract class BaseCellViewModel extends Disposable { return this._focusMode; } set focusMode(newMode: CellFocusMode) { - if (this._focusMode !== newMode) { - this._focusMode = newMode; - this._onDidChangeState.fire({ focusModeChanged: true }); - } + this._focusMode = newMode; + this._onDidChangeState.fire({ focusModeChanged: true }); } protected _textEditor?: ICodeEditor; From 7e87a0815a5df3a1fa919fca80437271683fdbc6 Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 6 Dec 2021 11:29:45 -0800 Subject: [PATCH 02/10] Use a unique authority for desktop webview too (#138529) Fixes #138409 This fix changes webviews on desktop to always use a unique authority instead of reusing the id passed in. In practice, this change should only effect internal webviews, such as those on extension pages or in getting started, since those were the only webviews that were using a hardcoded id This aligns webviews on desktop with web. --- src/vs/workbench/contrib/webview/browser/webviewElement.ts | 2 +- .../contrib/webview/electron-sandbox/webviewElement.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/webview/browser/webviewElement.ts b/src/vs/workbench/contrib/webview/browser/webviewElement.ts index 6797ecaec0b17..a85f8dd96aa63 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewElement.ts @@ -95,7 +95,7 @@ namespace WebviewState { export class WebviewElement extends Disposable implements IWebview, WebviewFindDelegate { public readonly id: string; - private readonly iframeId: string; + protected readonly iframeId: string; protected get platform(): string { return 'browser'; } diff --git a/src/vs/workbench/contrib/webview/electron-sandbox/webviewElement.ts b/src/vs/workbench/contrib/webview/electron-sandbox/webviewElement.ts index d1318e247ae2b..55ee9927e7628 100644 --- a/src/vs/workbench/contrib/webview/electron-sandbox/webviewElement.ts +++ b/src/vs/workbench/contrib/webview/electron-sandbox/webviewElement.ts @@ -91,7 +91,7 @@ export class ElectronWebviewElement extends WebviewElement { } protected override get webviewContentEndpoint(): string { - return `${Schemas.vscodeWebview}://${this.id}`; + return `${Schemas.vscodeWebview}://${this.iframeId}`; } /** From 9580998151f73ee39adbb8c23d9ed4abad8b127f Mon Sep 17 00:00:00 2001 From: Martin Aeschlimann Date: Mon, 6 Dec 2021 22:18:57 +0100 Subject: [PATCH 03/10] make sure theme is loaded when restoring it. Fixes #138422 (#138512) --- .../workbench/services/themes/browser/workbenchThemeService.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts index 08073f0ea6538..3f95ee603d0fd 100644 --- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts @@ -481,6 +481,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { if (settingId !== this.currentColorTheme.settingsId) { await this.internalSetColorTheme(theme.id, undefined); } else if (theme !== this.currentColorTheme) { + await theme.ensureLoaded(this.extensionResourceLoaderService); theme.setCustomizations(this.settings); await this.applyTheme(theme, undefined, true); } @@ -656,6 +657,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { if (settingId !== this.currentFileIconTheme.settingsId) { await this.internalSetFileIconTheme(theme.id, undefined); } else if (theme !== this.currentFileIconTheme) { + await theme.ensureLoaded(this.extensionResourceLoaderService); this.applyAndSetFileIconTheme(theme, true); } return true; @@ -761,6 +763,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { if (settingId !== this.currentProductIconTheme.settingsId) { await this.internalSetProductIconTheme(theme.id, undefined); } else if (theme !== this.currentProductIconTheme) { + await theme.ensureLoaded(this.extensionResourceLoaderService, this.logService); this.applyAndSetProductIconTheme(theme, true); } return true; From 7db1a2b88f7557e0a43fec75b6ba7e50b3e9f77e Mon Sep 17 00:00:00 2001 From: Robo Date: Tue, 7 Dec 2021 06:35:50 +0900 Subject: [PATCH 04/10] revert changes to User agent header (#138556) Co-authored-by: Sandeep Somavarapu --- .../extensionManagement/common/extensionGalleryService.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts index 6cea0d617fea2..f547bdb49cf03 100644 --- a/src/vs/platform/extensionManagement/common/extensionGalleryService.ts +++ b/src/vs/platform/extensionManagement/common/extensionGalleryService.ts @@ -1035,8 +1035,7 @@ export async function resolveMarketplaceHeaders(version: string, productService: } | undefined): Promise<{ [key: string]: string; }> { const headers: IHeaders = { 'X-Market-Client-Id': `VSCode ${version}`, - 'X-Market-Client-Version': version, - 'User-Agent': `VSCode (${productService.nameShort})`, + 'User-Agent': `VSCode ${version}` }; const uuid = await getServiceMachineId(environmentService, fileService, storageService); if (supportsTelemetry(productService, environmentService) && getTelemetryLevel(configurationService) === TelemetryLevel.USAGE) { From 93376c68dd5e6f5bd871c884b5162b96df95c1a2 Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Tue, 14 Dec 2021 16:41:26 +0100 Subject: [PATCH 05/10] Fixes microsoft/monaco-editor#2822 --- build/lib/treeshaking.js | 25 +++++++++++++++++++++++++ build/lib/treeshaking.ts | 27 +++++++++++++++++++++++++++ src/vs/platform/log/common/log.ts | 6 +++--- 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/build/lib/treeshaking.js b/build/lib/treeshaking.js index 41cb33809b04d..6f65b0fc363af 100644 --- a/build/lib/treeshaking.js +++ b/build/lib/treeshaking.js @@ -244,6 +244,28 @@ function nodeOrChildIsBlack(node) { function isSymbolWithDeclarations(symbol) { return !!(symbol && symbol.declarations); } +function isVariableStatementWithSideEffects(ts, node) { + if (!ts.isVariableStatement(node)) { + return false; + } + let hasSideEffects = false; + const visitNode = (node) => { + if (hasSideEffects) { + // no need to go on + return; + } + if (ts.isCallExpression(node)) { + // TODO: assuming `createDecorator` and `refineServiceDecorator` calls are side-effect free + const isSideEffectFree = /(createDecorator|refineServiceDecorator)/.test(node.getText()); + if (!isSideEffectFree) { + hasSideEffects = true; + } + } + node.forEachChild(visitNode); + }; + node.forEachChild(visitNode); + return hasSideEffects; +} function markNodes(ts, languageService, options) { const program = languageService.getProgram(); if (!program) { @@ -282,6 +304,9 @@ function markNodes(ts, languageService, options) { } return; } + if (isVariableStatementWithSideEffects(ts, node)) { + enqueue_black(node); + } if (ts.isExpressionStatement(node) || ts.isIfStatement(node) || ts.isIterationStatement(node, true) diff --git a/build/lib/treeshaking.ts b/build/lib/treeshaking.ts index f24b31e26ac90..483b7b07e049d 100644 --- a/build/lib/treeshaking.ts +++ b/build/lib/treeshaking.ts @@ -327,6 +327,29 @@ function isSymbolWithDeclarations(symbol: ts.Symbol | undefined | null): symbol return !!(symbol && symbol.declarations); } +function isVariableStatementWithSideEffects(ts: typeof import('typescript'), node: ts.Node): boolean { + if (!ts.isVariableStatement(node)) { + return false; + } + let hasSideEffects = false; + const visitNode = (node: ts.Node) => { + if (hasSideEffects) { + // no need to go on + return; + } + if (ts.isCallExpression(node)) { + // TODO: assuming `createDecorator` and `refineServiceDecorator` calls are side-effect free + const isSideEffectFree = /(createDecorator|refineServiceDecorator)/.test(node.getText()); + if (!isSideEffectFree) { + hasSideEffects = true; + } + } + node.forEachChild(visitNode); + }; + node.forEachChild(visitNode); + return hasSideEffects; +} + function markNodes(ts: typeof import('typescript'), languageService: ts.LanguageService, options: ITreeShakingOptions) { const program = languageService.getProgram(); if (!program) { @@ -372,6 +395,10 @@ function markNodes(ts: typeof import('typescript'), languageService: ts.Language return; } + if (isVariableStatementWithSideEffects(ts, node)) { + enqueue_black(node); + } + if ( ts.isExpressionStatement(node) || ts.isIfStatement(node) diff --git a/src/vs/platform/log/common/log.ts b/src/vs/platform/log/common/log.ts index a8a6ea1c7b505..88cc084a20246 100644 --- a/src/vs/platform/log/common/log.ts +++ b/src/vs/platform/log/common/log.ts @@ -9,10 +9,10 @@ import { Disposable, IDisposable } from 'vs/base/common/lifecycle'; import { isWindows } from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { createDecorator as createServiceDecorator } from 'vs/platform/instantiation/common/instantiation'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -export const ILogService = createServiceDecorator('logService'); -export const ILoggerService = createServiceDecorator('loggerService'); +export const ILogService = createDecorator('logService'); +export const ILoggerService = createDecorator('loggerService'); function now(): string { return new Date().toISOString(); From 5a1b4999493d49c857497ad481d73a737439f305 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Tue, 14 Dec 2021 11:26:32 +0100 Subject: [PATCH 06/10] Go back to using `setImmediate` for background tokenization (#138887) --- src/vs/base/common/platform.ts | 19 +++++++++++++++++++ src/vs/editor/common/model/textModelTokens.ts | 10 +++++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/vs/base/common/platform.ts b/src/vs/base/common/platform.ts index aa1e3dc4e1a59..dd5cd3c9e2fc6 100644 --- a/src/vs/base/common/platform.ts +++ b/src/vs/base/common/platform.ts @@ -39,6 +39,7 @@ export interface INodeProcess { platform: string; arch: string; env: IProcessEnvironment; + nextTick?: (callback: (...args: any[]) => void) => void; versions?: { electron?: string; }; @@ -189,6 +190,10 @@ export const locale = _locale; */ export const translationsConfigFile = _translationsConfigFile; +interface ISetImmediate { + (callback: (...args: unknown[]) => void): void; +} + /** * See https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#:~:text=than%204%2C%20then-,set%20timeout%20to%204,-. * @@ -227,6 +232,20 @@ export const setTimeout0 = (() => { return (callback: () => void) => setTimeout(callback); })(); +export const setImmediate: ISetImmediate = (function defineSetImmediate() { + if (globals.setImmediate) { + return globals.setImmediate.bind(globals); + } + if (typeof globals.postMessage === 'function' && !globals.importScripts) { + return setTimeout0; + } + if (typeof nodeProcess?.nextTick === 'function') { + return nodeProcess.nextTick.bind(nodeProcess); + } + const _promise = Promise.resolve(); + return (callback: (...args: unknown[]) => void) => _promise.then(callback); +})(); + export const enum OperatingSystem { Windows = 1, Macintosh = 2, diff --git a/src/vs/editor/common/model/textModelTokens.ts b/src/vs/editor/common/model/textModelTokens.ts index cabbec3264226..45ca7d8658716 100644 --- a/src/vs/editor/common/model/textModelTokens.ts +++ b/src/vs/editor/common/model/textModelTokens.ts @@ -15,7 +15,7 @@ import { TextModel } from 'vs/editor/common/model/textModel'; import { Disposable } from 'vs/base/common/lifecycle'; import { StopWatch } from 'vs/base/common/stopwatch'; import { MultilineTokensBuilder, countEOL } from 'vs/editor/common/model/tokensStore'; -import { runWhenIdle, IdleDeadline } from 'vs/base/common/async'; +import { setImmediate } from 'vs/base/common/platform'; const enum Constants { CHEAP_TOKENIZATION_LENGTH_LIMIT = 2048 @@ -262,7 +262,7 @@ export class TextModelTokenization extends Disposable { } this._isScheduled = true; - runWhenIdle((deadline) => { + setImmediate(() => { this._isScheduled = false; if (this._isDisposed) { @@ -270,11 +270,11 @@ export class TextModelTokenization extends Disposable { return; } - this._revalidateTokensNow(deadline); + this._revalidateTokensNow(); }); } - private _revalidateTokensNow(deadline: IdleDeadline): void { + private _revalidateTokensNow(): void { const textModelLastLineNumber = this._textModel.getLineCount(); const MAX_ALLOWED_TIME = 1; @@ -293,7 +293,7 @@ export class TextModelTokenization extends Disposable { if (tokenizedLineNumber >= textModelLastLineNumber) { break; } - } while (this._hasLinesToTokenize() && deadline.timeRemaining() > 0); + } while (this._hasLinesToTokenize()); this._beginBackgroundTokenization(); this._textModel.setTokens(builder.tokens, !this._hasLinesToTokenize()); From fbc3d68649c26d9d7bd4b608ce36fa9f71477207 Mon Sep 17 00:00:00 2001 From: Mariana Capelo Date: Tue, 17 May 2022 10:36:50 +0100 Subject: [PATCH 07/10] Apply OS changes (#21) --- .../os-monaco-core-pipeline.yml | 63 +++++++++++++++++++ build/monaco/package.json | 2 +- src/vs/editor/common/modes.ts | 4 ++ .../contrib/suggest/suggestWidgetRenderer.ts | 10 ++- 4 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 build/azure-pipelines/os-monaco-core-pipeline.yml diff --git a/build/azure-pipelines/os-monaco-core-pipeline.yml b/build/azure-pipelines/os-monaco-core-pipeline.yml new file mode 100644 index 0000000000000..5f81dca2dadc1 --- /dev/null +++ b/build/azure-pipelines/os-monaco-core-pipeline.yml @@ -0,0 +1,63 @@ +pool: + vmImage: 'windows-latest' + +trigger: + branches: + include: + - main-os +pr: none + +variables: + TagName: 'v$(Build.BuildNumber)' + +stages: +- stage: Build + displayName: 'Build' + jobs: + - job: Build + displayName: 'Build Job' + steps: + - task: NodeTool@0 + inputs: + versionSpec: "12.14.1" + - script: | + yarn + - script: | + ./node_modules/.bin/gulp editor-distro + - task: PublishPipelineArtifact@1 + inputs: + targetPath: './out-monaco-editor-core' + artifact: 'artifacts' + publishLocation: 'pipeline' + + +- stage: Deploy + displayName: 'Deploy' + jobs: + - deployment: Deploy + displayName: 'Deploy to npm private repository and creates a git release' + pool: + vmImage: 'windows-latest' + environment: Automatic-Release + strategy: + runOnce: + deploy: + steps: + #Creates a Github release + - task: GitHubRelease@1 + inputs: + gitHubConnection: 'GitHub Release' + repositoryName: '$(Build.Repository.Name)' + action: 'create' + target: '$(Build.SourceVersion)' + tagSource: 'userSpecifiedTag' + tag: '$(TagName)' + changeLogCompareToRelease: 'lastFullRelease' + changeLogType: 'commitBased' + #Publishes the package into the private artifact repository + - task: Npm@1 + inputs: + command: 'publish' + workingDir: '$(Pipeline.Workspace)/artifacts/' + publishRegistry: 'useFeed' + publishFeed: 'd8b4d1eb-aeb3-4b5b-9b43-37b4fc985e2f' diff --git a/build/monaco/package.json b/build/monaco/package.json index 48f2d3a50b3d7..91adf7142700d 100644 --- a/build/monaco/package.json +++ b/build/monaco/package.json @@ -1,7 +1,7 @@ { "name": "monaco-editor-core", "private": true, - "version": "0.31.0", + "version": "0.31.0-os", "description": "A browser based code editor", "author": "Microsoft Corporation", "license": "MIT", diff --git a/src/vs/editor/common/modes.ts b/src/vs/editor/common/modes.ts index ceaff9385dd1f..1282a56fead60 100644 --- a/src/vs/editor/common/modes.ts +++ b/src/vs/editor/common/modes.ts @@ -572,6 +572,10 @@ export interface CompletionItem { * A command that should be run upon acceptance of this item. */ command?: Command; + /** + * Custom icon to be used (instead of those ones that depend on the completionItem kind) + */ + customIcon?: HTMLElement; /** * @internal diff --git a/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts b/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts index aca7b0cbcce99..466bf6340d003 100644 --- a/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts +++ b/src/vs/editor/contrib/suggest/suggestWidgetRenderer.ts @@ -171,8 +171,16 @@ export class ItemRenderer implements IListRenderer Date: Tue, 17 May 2022 10:46:37 +0100 Subject: [PATCH 08/10] Update pipeline --- build/azure-pipelines/os-monaco-core-pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build/azure-pipelines/os-monaco-core-pipeline.yml b/build/azure-pipelines/os-monaco-core-pipeline.yml index 5f81dca2dadc1..257514f163e8f 100644 --- a/build/azure-pipelines/os-monaco-core-pipeline.yml +++ b/build/azure-pipelines/os-monaco-core-pipeline.yml @@ -1,5 +1,5 @@ pool: - vmImage: 'windows-latest' + vmImage: 'windows-2019' trigger: branches: @@ -19,7 +19,7 @@ stages: steps: - task: NodeTool@0 inputs: - versionSpec: "12.14.1" + versionSpec: "14.17.3" - script: | yarn - script: | @@ -37,7 +37,7 @@ stages: - deployment: Deploy displayName: 'Deploy to npm private repository and creates a git release' pool: - vmImage: 'windows-latest' + vmImage: 'windows-2019' environment: Automatic-Release strategy: runOnce: From 75e008507733e1474db9e5d80740330c5f086db9 Mon Sep 17 00:00:00 2001 From: Mariana Capelo Date: Wed, 25 May 2022 14:46:47 +0100 Subject: [PATCH 09/10] Update version based on npm info --- build/monaco/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/monaco/package.json b/build/monaco/package.json index 91adf7142700d..7170c3e8b502e 100644 --- a/build/monaco/package.json +++ b/build/monaco/package.json @@ -1,7 +1,7 @@ { "name": "monaco-editor-core", "private": true, - "version": "0.31.0-os", + "version": "0.31.1-os", "description": "A browser based code editor", "author": "Microsoft Corporation", "license": "MIT", From 92cc555f14cec0acc6d2da6b148deb996c62cfae Mon Sep 17 00:00:00 2001 From: Luis Oliveira Date: Thu, 12 Oct 2023 13:41:57 +0100 Subject: [PATCH 10/10] Fix https://github.com/microsoft/vscode/pull/178795 (#24) --- build/monaco/package.json | 2 +- src/vs/editor/browser/controller/mouseTarget.ts | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/build/monaco/package.json b/build/monaco/package.json index 7170c3e8b502e..dca91c1c044aa 100644 --- a/build/monaco/package.json +++ b/build/monaco/package.json @@ -1,7 +1,7 @@ { "name": "monaco-editor-core", "private": true, - "version": "0.31.1-os", + "version": "0.31.1-os2", "description": "A browser based code editor", "author": "Microsoft Corporation", "license": "MIT", diff --git a/src/vs/editor/browser/controller/mouseTarget.ts b/src/vs/editor/browser/controller/mouseTarget.ts index e6dc5ca034a30..aab294bb4bbd1 100644 --- a/src/vs/editor/browser/controller/mouseTarget.ts +++ b/src/vs/editor/browser/controller/mouseTarget.ts @@ -991,8 +991,14 @@ export function shadowCaretRangeFromPoint(shadowRoot: ShadowRoot, x: number, y: // Grab its rect const rect = el.getBoundingClientRect(); - // And its font - const font = window.getComputedStyle(el, null).getPropertyValue('font'); + // And its font (the computed shorthand font property might be empty, see #3217) + const fontStyle = window.getComputedStyle(el, null).getPropertyValue('font-style'); + const fontVariant = window.getComputedStyle(el, null).getPropertyValue('font-variant'); + const fontWeight = window.getComputedStyle(el, null).getPropertyValue('font-weight'); + const fontSize = window.getComputedStyle(el, null).getPropertyValue('font-size'); + const lineHeight = window.getComputedStyle(el, null).getPropertyValue('line-height'); + const fontFamily = window.getComputedStyle(el, null).getPropertyValue('font-family'); + const font = `${fontStyle} ${fontVariant} ${fontWeight} ${fontSize}/${lineHeight} ${fontFamily}`; // And also its txt content const text = (el as any).innerText;