Skip to content

Commit edb91ac

Browse files
committed
Merge branch 'main' into joh/vscode-dts
2 parents f161c7e + ec5486b commit edb91ac

File tree

34 files changed

+364
-135
lines changed

34 files changed

+364
-135
lines changed

extensions/emmet/src/abbreviationActions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export async function wrapWithAbbreviation(args: any): Promise<boolean> {
4949

5050
const helper = getEmmetHelper();
5151

52-
const operationRanges = editor.selections.sort((a, b) => a.start.compareTo(b.start)).map(selection => {
52+
const operationRanges = Array.from(editor.selections).sort((a, b) => a.start.compareTo(b.start)).map(selection => {
5353
let rangeToReplace: vscode.Range = selection;
5454
// wrap around the node if the selection falls inside its open or close tag
5555
{

extensions/emmet/src/balance.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { getHtmlFlatNode, offsetRangeToSelection, validate } from './util';
88
import { getRootNode } from './parseDocument';
99
import { HtmlNode as HtmlFlatNode } from 'EmmetFlatNode';
1010

11-
let balanceOutStack: Array<vscode.Selection[]> = [];
12-
let lastBalancedSelections: vscode.Selection[] = [];
11+
let balanceOutStack: Array<readonly vscode.Selection[]> = [];
12+
let lastBalancedSelections: readonly vscode.Selection[] = [];
1313

1414
export function balanceOut() {
1515
balance(true);
@@ -31,10 +31,8 @@ function balance(out: boolean) {
3131
}
3232

3333
const rangeFn = out ? getRangeToBalanceOut : getRangeToBalanceIn;
34-
let newSelections: vscode.Selection[] = [];
35-
editor.selections.forEach(selection => {
36-
const range = rangeFn(document, rootNode, selection);
37-
newSelections.push(range);
34+
let newSelections: readonly vscode.Selection[] = editor.selections.map(selection => {
35+
return rangeFn(document, rootNode, selection);
3836
});
3937

4038
// check whether we are starting a balance elsewhere
@@ -122,7 +120,7 @@ function getRangeToBalanceIn(document: vscode.TextDocument, rootNode: HtmlFlatNo
122120
return offsetRangeToSelection(document, firstChild.start, firstChild.end);
123121
}
124122

125-
function areSameSelections(a: vscode.Selection[], b: vscode.Selection[]): boolean {
123+
function areSameSelections(a: readonly vscode.Selection[], b: readonly vscode.Selection[]): boolean {
126124
if (a.length !== b.length) {
127125
return false;
128126
}

extensions/emmet/src/mergeLines.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function mergeLines() {
2121
}
2222

2323
return editor.edit(editBuilder => {
24-
editor.selections.reverse().forEach(selection => {
24+
Array.from(editor.selections).reverse().forEach(selection => {
2525
const textEdit = getRangesToReplace(editor.document, selection, rootNode);
2626
if (textEdit) {
2727
editBuilder.replace(textEdit.range, textEdit.newText);

extensions/emmet/src/removeTag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function removeTag() {
1919
return;
2020
}
2121

22-
let finalRangesToRemove = editor.selections.reverse()
22+
let finalRangesToRemove = Array.from(editor.selections).reverse()
2323
.reduce<vscode.Range[]>((prev, selection) =>
2424
prev.concat(getRangesToRemove(editor.document, rootNode, selection)), []);
2525

extensions/emmet/src/splitJoinTag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export function splitJoinTag() {
2121
}
2222

2323
return editor.edit(editBuilder => {
24-
editor.selections.reverse().forEach(selection => {
24+
Array.from(editor.selections).reverse().forEach(selection => {
2525
const documentText = document.getText();
2626
const offset = document.offsetAt(selection.start);
2727
const nodeToUpdate = getHtmlFlatNode(documentText, rootNode, offset, true);

extensions/emmet/src/toggleComment.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function toggleComment(): Thenable<boolean> | undefined {
2828

2929
return editor.edit(editBuilder => {
3030
let allEdits: vscode.TextEdit[][] = [];
31-
editor.selections.reverse().forEach(selection => {
31+
Array.from(editor.selections).reverse().forEach(selection => {
3232
const edits = isStyleSheet(editor.document.languageId) ? toggleCommentStylesheet(editor.document, selection, <Stylesheet>rootNode) : toggleCommentHTML(editor.document, selection, rootNode!);
3333
if (edits.length > 0) {
3434
allEdits.push(edits);

extensions/emmet/src/updateImageSize.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function updateImageSize(): Promise<boolean> | undefined {
2323
}
2424
const editor = window.activeTextEditor;
2525

26-
const allUpdatesPromise = editor.selections.reverse().map(selection => {
26+
const allUpdatesPromise = Array.from(editor.selections).reverse().map(selection => {
2727
const position = selection.isReversed ? selection.active : selection.anchor;
2828
if (!isStyleSheet(editor.document.languageId)) {
2929
return updateImageSizeHTML(editor, position);

extensions/emmet/src/updateTag.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function updateTag(tagName: string | undefined): Promise<boolean |
2525
return;
2626
}
2727

28-
const rangesToUpdate = editor.selections.reverse()
28+
const rangesToUpdate = Array.from(editor.selections).reverse()
2929
.reduce<TagRange[]>((prev, selection) =>
3030
prev.concat(getRangesToUpdate(document, selection, rootNode)), []);
3131
if (!rangesToUpdate.length) {

extensions/git/src/staging.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function applyLineChanges(original: TextDocument, modified: TextDocument,
4949
return result.join('');
5050
}
5151

52-
export function toLineRanges(selections: Selection[], textDocument: TextDocument): Range[] {
52+
export function toLineRanges(selections: readonly Selection[], textDocument: TextDocument): Range[] {
5353
const lineRanges = selections.map(s => {
5454
const startLine = textDocument.lineAt(s.start.line);
5555
const endLine = textDocument.lineAt(s.end.line);

extensions/git/src/test/smoke.test.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ suite('git smoke test', function () {
5656
git = ext!.exports.getAPI(1);
5757

5858
if (git.repositories.length === 0) {
59-
await eventToPromise(git.onDidOpenRepository);
59+
const onDidOpenRepository = eventToPromise(git.onDidOpenRepository);
60+
await commands.executeCommand('git.openRepository', cwd);
61+
await onDidOpenRepository;
6062
}
6163

6264
assert.strictEqual(git.repositories.length, 1);

extensions/markdown-language-features/preview-src/index.ts

+18
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ window.addEventListener('message', async event => {
134134
root.replaceWith(newContent.querySelector('.markdown-body')!);
135135
documentResource = event.data.source;
136136
} else {
137+
// Compare two elements but skip `data-line`
137138
const areEqual = (a: Element, b: Element): boolean => {
138139
if (a.isEqualNode(b)) {
139140
return true;
@@ -143,6 +144,23 @@ window.addEventListener('message', async event => {
143144
return false;
144145
}
145146

147+
const aAttrs = a.attributes;
148+
const bAttrs = b.attributes;
149+
if (aAttrs.length !== bAttrs.length) {
150+
return false;
151+
}
152+
153+
for (let i = 0; i < aAttrs.length; ++i) {
154+
const aAttr = aAttrs[i];
155+
const bAttr = bAttrs[i];
156+
if (aAttr.name !== bAttr.name) {
157+
return false;
158+
}
159+
if (aAttr.value !== bAttr.value && aAttr.name !== 'data-line') {
160+
return false;
161+
}
162+
}
163+
146164
const aChildren = Array.from(a.children);
147165
const bChildren = Array.from(b.children);
148166

extensions/markdown-language-features/src/test/documentLink.test.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@ function workspaceFile(...segments: string[]) {
1515
}
1616

1717
async function getLinksForFile(file: vscode.Uri): Promise<vscode.DocumentLink[]> {
18-
return (await vscode.commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', file))!;
18+
console.log('getting links', file.toString(), Date.now());
19+
const r = (await vscode.commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', file))!;
20+
console.log('got links', file.toString(), Date.now());
21+
return r;
1922
}
2023

21-
suite('Markdown Document links', () => {
24+
suite.skip('Markdown Document links', () => {
2225

2326
setup(async () => {
2427
// the tests make the assumption that link providers are already registered
@@ -94,7 +97,6 @@ suite('Markdown Document links', () => {
9497
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 1);
9598
});
9699

97-
98100
test('Should navigate to line number within non-md file', async () => {
99101
await withFileContents(testFileA, '[b](sub/foo.txt#L3)');
100102

@@ -147,15 +149,21 @@ function assertActiveDocumentUri(expectedUri: vscode.Uri) {
147149
}
148150

149151
async function withFileContents(file: vscode.Uri, contents: string): Promise<void> {
152+
console.log('openTextDocument', file.toString(), Date.now());
150153
const document = await vscode.workspace.openTextDocument(file);
154+
console.log('showTextDocument', file.toString(), Date.now());
151155
const editor = await vscode.window.showTextDocument(document);
156+
console.log('editTextDocument', file.toString(), Date.now());
152157
await editor.edit(edit => {
153158
edit.replace(new vscode.Range(0, 0, 1000, 0), contents);
154159
});
160+
console.log('opened done', vscode.window.activeTextEditor?.document.toString(), Date.now());
155161
}
156162

157163
async function executeLink(link: vscode.DocumentLink) {
164+
console.log('executeingLink', link.target?.toString(), Date.now());
165+
158166
const args = JSON.parse(decodeURIComponent(link.target!.query));
159167
await vscode.commands.executeCommand(link.target!.path, args);
168+
console.log('executedLink', vscode.window.activeTextEditor?.document.toString(), Date.now());
160169
}
161-

src/bootstrap-window.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@
4545
async function load(modulePaths, resultCallback, options) {
4646
const isDev = !!safeProcess.env['VSCODE_DEV'];
4747

48-
// Error handler (TODO@sandbox non-sandboxed only)
48+
// Error handler (node.js enabled renderers only)
4949
let showDevtoolsOnError = isDev;
50-
safeProcess.on('uncaughtException', function (/** @type {string | Error} */ error) {
51-
onUnexpectedError(error, showDevtoolsOnError);
52-
});
50+
if (!safeProcess.sandboxed) {
51+
safeProcess.on('uncaughtException', function (/** @type {string | Error} */ error) {
52+
onUnexpectedError(error, showDevtoolsOnError);
53+
});
54+
}
5355

5456
// Await window configuration from preload
5557
const timeout = setTimeout(() => { console.error(`[resolve window config] Could not resolve window configuration within 10 seconds, but will continue to wait...`); }, 10000);
@@ -83,7 +85,7 @@
8385
developerDeveloperKeybindingsDisposable = registerDeveloperKeybindings(disallowReloadKeybinding);
8486
}
8587

86-
// Enable ASAR support (TODO@sandbox non-sandboxed only)
88+
// Enable ASAR support (node.js enabled renderers only)
8789
if (!safeProcess.sandboxed) {
8890
globalThis.MonacoBootstrap.enableASARSupport(configuration.appRoot);
8991
}
@@ -100,9 +102,12 @@
100102

101103
window.document.documentElement.setAttribute('lang', locale);
102104

103-
// Replace the patched electron fs with the original node fs for all AMD code (TODO@sandbox non-sandboxed only)
105+
// Define `fs` as `original-fs` to disable ASAR support
106+
// in fs-operations (node.js enabled renderers only)
104107
if (!safeProcess.sandboxed) {
105-
require.define('fs', [], function () { return require.__$__nodeRequire('original-fs'); });
108+
require.define('fs', [], function () {
109+
return require.__$__nodeRequire('original-fs');
110+
});
106111
}
107112

108113
window['MonacoEnvironment'] = {};
@@ -140,8 +145,9 @@
140145
'tas-client-umd': `${baseNodeModulesPath}/tas-client-umd/lib/tas-client-umd.js`
141146
};
142147

143-
// For priviledged renderers, allow to load built-in and other node.js
144-
// modules via AMD which has a fallback to using node.js `require`
148+
// Allow to load built-in and other node.js modules via AMD
149+
// which has a fallback to using node.js `require`
150+
// (node.js enabled renderers only)
145151
if (!safeProcess.sandboxed) {
146152
loaderConfig.amdModulesPattern = /(^vs\/)|(^vscode-textmate$)|(^vscode-oniguruma$)|(^xterm$)|(^xterm-addon-search$)|(^xterm-addon-unicode11$)|(^xterm-addon-webgl$)|(^iconv-lite-umd$)|(^jschardet$)|(^@vscode\/vscode-languagedetection$)|(^tas-client-umd$)/;
147153
}

src/bootstrap.js

-3
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
//#region Add support for using node_modules.asar
4343

4444
/**
45-
* TODO@sandbox remove the support for passing in `appRoot` once
46-
* sandbox is fully enabled
47-
*
4845
* @param {string=} appRoot
4946
*/
5047
function enableASARSupport(appRoot) {

src/vs/base/browser/ui/menu/menubar.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface IMenuBarOptions {
3434
getKeybinding?: (action: IAction) => ResolvedKeybinding | undefined;
3535
alwaysOnMnemonics?: boolean;
3636
compactMode?: Direction;
37+
actionRunner?: IActionRunner;
3738
getCompactMenuActions?: () => IAction[]
3839
}
3940

@@ -109,7 +110,7 @@ export class MenuBar extends Disposable {
109110

110111
this.menuUpdater = this._register(new RunOnceScheduler(() => this.update(), 200));
111112

112-
this.actionRunner = this._register(new ActionRunner());
113+
this.actionRunner = this.options.actionRunner ?? this._register(new ActionRunner());
113114
this._register(this.actionRunner.onBeforeRun(() => {
114115
this.setUnfocusedState();
115116
}));

src/vs/platform/actions/common/actions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ export class MenuId {
101101
static readonly ExplorerContext = new MenuId('ExplorerContext');
102102
static readonly ExtensionContext = new MenuId('ExtensionContext');
103103
static readonly GlobalActivity = new MenuId('GlobalActivity');
104+
static readonly LayoutControlMenu = new MenuId('LayoutControlMenu');
104105
static readonly MenubarMainMenu = new MenuId('MenubarMainMenu');
105106
static readonly MenubarAppearanceMenu = new MenuId('MenubarAppearanceMenu');
106107
static readonly MenubarDebugMenu = new MenuId('MenubarDebugMenu');

0 commit comments

Comments
 (0)