Skip to content

Commit eadf1c4

Browse files
committed
Merge remote-tracking branch 'origin/main' into tyriar/127878
2 parents ebd2d0a + 273470f commit eadf1c4

File tree

140 files changed

+1991
-1389
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+1991
-1389
lines changed

build/azure-pipelines/common/installPlaywright.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*--------------------------------------------------------------------------------------------*/
66
Object.defineProperty(exports, "__esModule", { value: true });
77
const retry_1 = require("./retry");
8-
const { installDefaultBrowsersForNpmInstall } = require('playwright/lib/utils/registry');
8+
const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
99
async function install() {
1010
await (0, retry_1.retry)(() => installDefaultBrowsersForNpmInstall());
1111
}

build/azure-pipelines/common/installPlaywright.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { retry } from './retry';
7-
const { installDefaultBrowsersForNpmInstall } = require('playwright/lib/utils/registry');
7+
const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
88

99
async function install() {
1010
await retry(() => installDefaultBrowsersForNpmInstall());

build/filters.js

+30
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,36 @@ module.exports.all = [
2424
'!**/node_modules/**',
2525
];
2626

27+
module.exports.unicodeFilter = [
28+
'**',
29+
30+
'!**/ThirdPartyNotices.txt',
31+
'!**/LICENSE.{txt,rtf}',
32+
'!LICENSES.chromium.html',
33+
'!**/LICENSE',
34+
35+
'!**/*.{dll,exe,png,bmp,jpg,scpt,cur,ttf,woff,eot,template,ico,icns}',
36+
'!**/test/**',
37+
'!**/*.test.ts',
38+
'!**/*.{d.ts,json,md}',
39+
40+
'!build/win32/**',
41+
'!extensions/markdown-language-features/notebook-out/*.js',
42+
'!extensions/markdown-math/notebook-out/**',
43+
'!extensions/php-language-features/src/features/phpGlobalFunctions.ts',
44+
'!extensions/typescript-language-features/test-workspace/**',
45+
'!extensions/vscode-api-tests/testWorkspace/**',
46+
'!extensions/vscode-api-tests/testWorkspace2/**',
47+
'!extensions/vscode-custom-editor-tests/test-workspace/**',
48+
'!extensions/**/dist/**',
49+
'!extensions/**/out/**',
50+
'!extensions/**/snippets/**',
51+
'!extensions/**/colorize-fixtures/**',
52+
53+
'!src/vs/base/browser/dompurify/**',
54+
'!src/vs/workbench/services/keybinding/browser/keyboardLayouts/**',
55+
];
56+
2757
module.exports.indentationFilter = [
2858
'**',
2959

build/hygiene.js

+31-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const vfs = require('vinyl-fs');
1010
const path = require('path');
1111
const fs = require('fs');
1212
const pall = require('p-all');
13-
const { all, copyrightFilter, indentationFilter, jsHygieneFilter, tsHygieneFilter } = require('./filters');
13+
const { all, copyrightFilter, unicodeFilter, indentationFilter, jsHygieneFilter, tsHygieneFilter } = require('./filters');
1414

1515
const copyrightHeaderLines = [
1616
'/*---------------------------------------------------------------------------------------------',
@@ -36,10 +36,35 @@ function hygiene(some, linting = true) {
3636
this.emit('data', file);
3737
});
3838

39-
const indentation = es.through(function (file) {
39+
const unicode = es.through(function (file) {
4040
const lines = file.contents.toString('utf8').split(/\r\n|\r|\n/);
4141
file.__lines = lines;
4242

43+
let skipNext = false;
44+
lines.forEach((line, i) => {
45+
if (/allow-any-unicode-next-line/.test(line)) {
46+
skipNext = true;
47+
return;
48+
}
49+
if (skipNext) {
50+
skipNext = false;
51+
return;
52+
}
53+
// Please do not add symbols that resemble ASCII letters!
54+
const m = /([^\t\n\r\x20-\x7E🎯🛑🔴🚗🚙🚕🎉×÷¦·φ]+)/g.exec(line);
55+
if (m) {
56+
console.error(
57+
file.relative + `(${i + 1},${m.index + 1}): Unexpected unicode character: "${m[0]}". To suppress, use // allow-any-unicode-next-line`
58+
);
59+
errorCount++;
60+
}
61+
});
62+
});
63+
64+
const indentation = es.through(function (file) {
65+
const lines = file.__lines || file.contents.toString('utf8').split(/\r\n|\r|\n/);
66+
file.__lines = lines;
67+
4368
lines.forEach((line, i) => {
4469
if (/^\s*$/.test(line)) {
4570
// empty or whitespace lines are OK
@@ -121,12 +146,16 @@ function hygiene(some, linting = true) {
121146
}
122147

123148
const productJsonFilter = filter('product.json', { restore: true });
149+
const unicodeFilterStream = filter(unicodeFilter, { restore: true });
124150

125151
const result = input
126152
.pipe(filter((f) => !f.stat.isDirectory()))
127153
.pipe(productJsonFilter)
128154
.pipe(process.env['BUILD_SOURCEVERSION'] ? es.through() : productJson)
129155
.pipe(productJsonFilter.restore)
156+
.pipe(unicodeFilterStream)
157+
.pipe(unicode)
158+
.pipe(unicodeFilterStream.restore)
130159
.pipe(filter(indentationFilter))
131160
.pipe(indentation)
132161
.pipe(filter(copyrightFilter))

extensions/emmet/src/evaluateMathExpression.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function evaluateMathExpression(): Thenable<boolean> {
4242
}
4343
} catch (err) {
4444
vscode.window.showErrorMessage('Could not evaluate expression');
45-
// Ignore error since most likely its because of non-math expression
45+
// Ignore error since most likely it's because of non-math expression
4646
console.warn('Math evaluation error', err);
4747
}
4848
});

extensions/emmet/src/locateFile.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const reAbsoluteWin32 = /^\\+/;
1616
const reAbsolute = path.sep === '/' ? reAbsolutePosix : reAbsoluteWin32;
1717

1818
/**
19-
* Locates given `filePath` on users file system and returns absolute path to it.
19+
* Locates given `filePath` on user's file system and returns absolute path to it.
2020
* This method expects either URL, or relative/absolute path to resource
2121
* @param basePath Base path to use if filePath is not absoulte
2222
* @param filePath File to locate.
@@ -43,7 +43,7 @@ function resolveRelative(basePath: string, filePath: string): Promise<string> {
4343

4444
/**
4545
* Resolves absolute file path agaist given editor: tries to find file in every
46-
* parent of editors file
46+
* parent of editor's file
4747
*/
4848
function resolveAbsolute(basePath: string, filePath: string): Promise<string> {
4949
return new Promise((resolve, reject) => {
@@ -66,7 +66,7 @@ function resolveAbsolute(basePath: string, filePath: string): Promise<string> {
6666
}
6767

6868
/**
69-
* Check if given file exists and its a file, not directory
69+
* Check if given file exists and it's a file, not directory
7070
*/
7171
function tryFile(file: string): Promise<string> {
7272
return new Promise((resolve, reject) => {

extensions/emmet/src/updateImageSize.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ function updateImageSizeHTML(editor: TextEditor, position: Position): Promise<Te
5858
return locateFile(path.dirname(editor.document.fileName), src)
5959
.then(getImageSize)
6060
.then((size: any) => {
61-
// since this action is asynchronous, we have to ensure that editor wasnt
62-
// changed and user didnt moved caret outside <img> node
61+
// since this action is asynchronous, we have to ensure that editor wasn't
62+
// changed and user didn't moved caret outside <img> node
6363
const img = getImageHTMLNode(editor, position);
6464
if (img && getImageSrcHTML(img) === src) {
6565
return updateHTMLTag(editor, img, size.width, size.height);
@@ -109,8 +109,8 @@ function updateImageSizeCSS(editor: TextEditor, position: Position, fetchNode: (
109109
return locateFile(path.dirname(editor.document.fileName), src)
110110
.then(getImageSize)
111111
.then((size: any): TextEdit[] => {
112-
// since this action is asynchronous, we have to ensure that editor wasnt
113-
// changed and user didnt moved caret outside <img> node
112+
// since this action is asynchronous, we have to ensure that editor wasn't
113+
// changed and user didn't moved caret outside <img> node
114114
const prop = fetchNode(editor, position);
115115
if (prop && getImageSrcCSS(editor, prop, position) === src) {
116116
return updateCSSNode(editor, prop, size.width, size.height);
@@ -259,7 +259,7 @@ function getAttribute(node: HtmlNode, attrName: string): Attribute | undefined {
259259

260260
/**
261261
* Returns quote character, used for value of given attribute. May return empty
262-
* string if attribute wasnt quoted
262+
* string if attribute wasn't quoted
263263
264264
*/
265265
function getAttributeQuote(editor: TextEditor, attr: Attribute): string {
@@ -290,7 +290,7 @@ function findUrlToken(editor: TextEditor, node: Property, pos: Position): CssTok
290290
}
291291

292292
/**
293-
* Returns a string that is used to delimit properties in current nodes rule
293+
* Returns a string that is used to delimit properties in current node's rule
294294
*/
295295
function getPropertyDelimitor(editor: TextEditor, node: Property): string {
296296
let anchor;

extensions/git/src/timelineProvider.ts

+3
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export class GitTimelineProvider implements TimelineProvider {
166166
if (showAuthor) {
167167
item.description = c.authorName;
168168
}
169+
// allow-any-unicode-next-line
169170
item.detail = `${c.authorName} (${c.authorEmail}) — ${c.hash.substr(0, 8)}\n${dateFormatter.format(date)}\n\n${message}`;
170171

171172
const cmd = this.commands.resolveTimelineOpenDiffCommand(item, uri);
@@ -191,6 +192,7 @@ export class GitTimelineProvider implements TimelineProvider {
191192
// TODO@eamodio: Replace with a better icon -- reflecting its status maybe?
192193
item.iconPath = new ThemeIcon('git-commit');
193194
item.description = '';
195+
// allow-any-unicode-next-line
194196
item.detail = localize('git.timeline.detail', '{0} — {1}\n{2}\n\n{3}', you, localize('git.index', 'Index'), dateFormatter.format(date), Resource.getStatusText(index.type));
195197

196198
const cmd = this.commands.resolveTimelineOpenDiffCommand(item, uri);
@@ -213,6 +215,7 @@ export class GitTimelineProvider implements TimelineProvider {
213215
// TODO@eamodio: Replace with a better icon -- reflecting its status maybe?
214216
item.iconPath = new ThemeIcon('git-commit');
215217
item.description = '';
218+
// allow-any-unicode-next-line
216219
item.detail = localize('git.timeline.detail', '{0} — {1}\n{2}\n\n{3}', you, localize('git.workingTree', 'Working Tree'), dateFormatter.format(date), Resource.getStatusText(working.type));
217220

218221
const cmd = this.commands.resolveTimelineOpenDiffCommand(item, uri);

extensions/ipynb/src/ipynbMain.ts

-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ export function activate(context: vscode.ExtensionContext) {
3333
transientOutputs: false,
3434
transientCellMetadata: {
3535
breakpointMargin: true,
36-
inputCollapsed: true,
37-
outputCollapsed: true,
3836
custom: false
3937
}
4038
}));

extensions/markdown-language-features/notebook/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ function slugFromHeading(heading: string): string {
233233
heading.trim()
234234
.toLowerCase()
235235
.replace(/\s+/g, '-') // Replace whitespace with -
236+
// allow-any-unicode-next-line
236237
.replace(/[\]\[\!\'\#\$\%\&\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\_\{\|\}\~\`·ˉ¨]/g, '') // Remove known punctuators
237238
.replace(/^\-+/, '') // Remove leading -
238239
.replace(/\-+$/, '') // Remove trailing -

extensions/markdown-language-features/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
"editor/title": [
100100
{
101101
"command": "markdown.showPreviewToSide",
102-
"when": "editorLangId == markdown && !notebookEditorFocused",
102+
"when": "editorLangId == markdown && !notebookEditorFocused && !hasCustomMarkdownPreview",
103103
"alt": "markdown.showPreview",
104104
"group": "navigation"
105105
},

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

+64-12
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import { SettingsManager, getData } from './settings';
1111
import throttle = require('lodash.throttle');
1212
import morphdom from 'morphdom';
1313

14-
let documentVersion = 0;
1514
let scrollDisabledCount = 0;
15+
1616
const marker = new ActiveLineMarker();
1717
const settings = new SettingsManager();
1818

19+
let documentVersion = 0;
20+
let documentResource = settings.settings.source;
21+
1922
const vscode = acquireVsCodeApi();
2023

2124
const originalState = vscode.getState();
@@ -101,36 +104,85 @@ const onUpdateView = (() => {
101104
};
102105
})();
103106

104-
105107
window.addEventListener('resize', () => {
106108
scrollDisabledCount += 1;
107109
updateScrollProgress();
108110
}, true);
109111

110-
window.addEventListener('message', event => {
111-
if (settings.settings && event.data.source !== settings.settings.source) {
112-
return;
113-
}
112+
window.addEventListener('message', async event => {
114113

115114
switch (event.data.type) {
116115
case 'onDidChangeTextEditorSelection':
117-
marker.onDidChangeTextEditorSelection(event.data.line, documentVersion);
118-
break;
116+
if (event.data.source === documentResource) {
117+
marker.onDidChangeTextEditorSelection(event.data.line, documentVersion);
118+
}
119+
return;
119120

120121
case 'updateView':
121-
onUpdateView(event.data.line);
122-
break;
122+
if (event.data.source === documentResource) {
123+
console.log('updateView', event.data.line);
124+
onUpdateView(event.data.line);
125+
}
126+
return;
123127

124128
case 'updateContent':
125129
const root = document.querySelector('.markdown-body')!;
126-
morphdom(root, event.data.content);
130+
131+
const parser = new DOMParser();
132+
const newContent = parser.parseFromString(event.data.content, 'text/html');
133+
134+
if (event.data.source !== documentResource) {
135+
root.replaceWith(newContent.querySelector('.markdown-body')!);
136+
documentResource = event.data.source;
137+
} else {
138+
const areEqual = (a: Element, b: Element): boolean => {
139+
if (a.isEqualNode(b)) {
140+
return true;
141+
}
142+
143+
if (a.tagName !== b.tagName || a.textContent !== b.textContent) {
144+
return false;
145+
}
146+
147+
const aChildren = Array.from(a.children);
148+
const bChildren = Array.from(b.children);
149+
150+
return aChildren.length === bChildren.length && aChildren.every((x, i) => areEqual(x, bChildren[i]));
151+
};
152+
153+
const newRoot = newContent.querySelector('.markdown-body')!;
154+
155+
// Move styles to head
156+
// This prevents an ugly flash of unstyled content
157+
const styles = newRoot.querySelectorAll('link');
158+
159+
for (const style of styles) {
160+
style.remove();
161+
}
162+
newRoot.prepend(...styles);
163+
164+
morphdom(root, newRoot, {
165+
childrenOnly: true,
166+
onBeforeElUpdated: (fromEl, toEl) => {
167+
if (areEqual(fromEl, toEl)) {
168+
fromEl.setAttribute('data-line', toEl.getAttribute('data-line')!);
169+
return false;
170+
}
171+
172+
return true;
173+
}
174+
});
175+
}
176+
127177
++documentVersion;
128178

129179
window.dispatchEvent(new CustomEvent('vscode.markdown.updateContent'));
130180
break;
131181
}
132182
}, false);
133183

184+
185+
134186
document.addEventListener('dblclick', event => {
135187
if (!settings.settings.doubleClickToSwitchToEditor) {
136188
return;
@@ -189,7 +241,7 @@ document.addEventListener('click', event => {
189241

190242
window.addEventListener('scroll', throttle(() => {
191243
updateScrollProgress();
192-
244+
console.log('scroll');
193245
if (scrollDisabledCount > 0) {
194246
scrollDisabledCount -= 1;
195247
} else {

0 commit comments

Comments
 (0)