monaco-editor-core 0.58.0-dev-20261103 → 0.58.0-dev-20261104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Version: 0.58.0-dev-20261103(0560dc36b303beb7f4ad05a772be7d1fe5b55063)
3
+ * Version: 0.58.0-dev-20261104(cd3e7d41600c2da14b71d0285a7fbd9b2bb8a965)
4
4
  * Released under the MIT license
5
5
  * https://github.com/microsoft/vscode/blob/main/LICENSE.txt
6
6
  *-----------------------------------------------------------*/
@@ -6,7 +6,6 @@ import { illegalArgument } from './errors.js';
6
6
  import { escapeIcons } from './iconLabels.js';
7
7
  import { matchesSomeScheme, Schemas } from './network.js';
8
8
  import { dirname, isEqual, resolvePath } from './resources.js';
9
- import { escapeRegExpCharacters } from './strings.js';
10
9
  import { URI } from './uri.js';
11
10
  export class MarkdownString {
12
11
  constructor(value = '', isTrustedOrOptions = false) {
@@ -42,29 +41,64 @@ export class MarkdownString {
42
41
  this.value += `\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\n`;
43
42
  return this;
44
43
  }
44
+ /**
45
+ * Appends a link.
46
+ *
47
+ * @param target The link target, used literally: it cannot end the link or add Markdown.
48
+ * It is not validated, so check the scheme of untrusted targets before using them in trusted Markdown.
49
+ * @param label The link text as Markdown. Use {@link escapeMarkdownLinkLabel} for plain text.
50
+ * @param title The link title, used literally.
51
+ */
45
52
  appendLink(target, label, title) {
46
53
  this.value += '[';
47
54
  this.value += this._escape(label, ']');
48
55
  this.value += '](';
49
- this.value += this._escape(String(target), ')');
56
+ this.value += escapeMarkdownLinkDestination(String(target));
50
57
  if (title) {
51
- this.value += ` "${this._escape(this._escape(title, '"'), ')')}"`;
58
+ this.value += ` "${escapeMarkdownLinkTitle(title)}"`;
52
59
  }
53
60
  this.value += ')';
54
61
  return this;
55
62
  }
56
63
  _escape(value, ch) {
57
- const r = new RegExp(escapeRegExpCharacters(ch), 'g');
58
- return value.replace(r, (match, offset) => {
59
- if (value.charAt(offset - 1) !== '\\') {
60
- return `\\${match}`;
64
+ // A delimiter is already escaped only if it follows an odd number of backslashes:
65
+ // in `\\]` the first backslash escapes the second one, which leaves `]` unescaped.
66
+ // A trailing odd run of backslashes is completed as well, so that it cannot escape
67
+ // the delimiter that is appended after the value.
68
+ let result = '';
69
+ let backslashes = 0;
70
+ for (const c of value) {
71
+ if (c === ch && backslashes % 2 === 0) {
72
+ result += '\\';
61
73
  }
62
- else {
63
- return match;
64
- }
65
- });
74
+ backslashes = c === '\\' ? backslashes + 1 : 0;
75
+ result += c;
76
+ }
77
+ return backslashes % 2 === 1 ? result + '\\' : result;
66
78
  }
67
79
  }
80
+ /**
81
+ * Escapes a string for use as a Markdown link destination: whitespace and control characters,
82
+ * which would end the destination, are percent-encoded and Markdown syntax is backslash-escaped.
83
+ */
84
+ function escapeMarkdownLinkDestination(target) {
85
+ return target
86
+ .replace(/[\s\x00-\x1f\x7f]/g, ch => encodeURIComponent(ch))
87
+ .replace(/[\\()<>]/g, '\\$&');
88
+ }
89
+ /**
90
+ * Escapes a string for use as a double-quoted Markdown link title. Line breaks are replaced,
91
+ * because an empty line would end the paragraph and with it the link. Characters that the
92
+ * Markdown parser interprets in titles are written as character references, not backslash
93
+ * escapes: marked reads `\\"` as an escaped quote, so a title ending in a backslash would
94
+ * otherwise extend into the following text.
95
+ */
96
+ function escapeMarkdownLinkTitle(title) {
97
+ return title
98
+ .replace(/\r\n|[\r\n]/g, ' ')
99
+ .replace(/\0/g, '\uFFFD') // HTML cannot represent NUL
100
+ .replace(/[&\\"()\t]/g, ch => `&#${ch.charCodeAt(0)};`);
101
+ }
68
102
  export function isEmptyMarkdownString(oneOrMany) {
69
103
  if (isMarkdownString(oneOrMany)) {
70
104
  return !oneOrMany.value;
@@ -110,6 +144,18 @@ export function escapeMarkdownSyntaxTokens(text) {
110
144
  .replace(/[\\`*_{}[\]()#+!~]/g, '\\$&') // CodeQL [SM02383] Backslash is escaped in the character class
111
145
  .replace(/^([ \t]*)-/gm, '$1\\-'); // CodeQL [SM02383] Backslash is escaped in the character class
112
146
  }
147
+ /**
148
+ * Escapes plain text for use as the text of a Markdown link, for example the label of
149
+ * {@link MarkdownString.appendLink}, so that it renders literally. Unlike
150
+ * {@link escapeMarkdownLinkLabel}, this also prevents autolinks, emphasis, code spans and
151
+ * character references: every ASCII punctuation character is backslash-escaped. Line breaks
152
+ * are replaced with spaces, because an empty line would end the paragraph and with it the link.
153
+ */
154
+ export function escapeMarkdownLinkText(text) {
155
+ return text
156
+ .replace(/\r\n|[\r\n]/g, ' ')
157
+ .replace(/[!-/:-@[-`{-~]/g, '\\$&'); // CodeQL [SM02383] All ASCII punctuation, including the backslash, is escaped
158
+ }
113
159
  /**
114
160
  * @see https://github.com/microsoft/vscode/issues/193746
115
161
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/htmlContent.ts","vs/base/common/htmlContent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,GAAG,EAAiB,MAAM,UAAU,CAAC;AAsB9C,MAAM,OAAO,cAAc;IAU1B,YACC,QAAgB,EAAE,EAClB,qBAAyK,KAAK;QAE9K,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,OAAO,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC;YACpC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC/B,IAAI,CA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vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { illegalArgument } from './errors.js';\nimport { escapeIcons } from './iconLabels.js';\nimport { matchesSomeScheme, Schemas } from './network.js';\nimport { dirname, isEqual, resolvePath } from './resources.js';\nimport { escapeRegExpCharacters } from './strings.js';\nimport { URI, UriComponents } from './uri.js';\n\nexport interface MarkdownStringTrustedOptions {\n\treadonly enabledCommands: readonly string[];\n}\n\nexport interface IMarkdownString {\n\treadonly value: string;\n\treadonly isTrusted?: boolean | MarkdownStringTrustedOptions;\n\treadonly supportThemeIcons?: boolean;\n\treadonly supportHtml?: boolean;\n\t/** @internal */\n\treadonly supportAlertSyntax?: boolean;\n\treadonly baseUri?: UriComponents;\n\turis?: { [href: string]: UriComponents };\n}\n\nexport const enum MarkdownStringTextNewlineStyle {\n\tParagraph = 0,\n\tBreak = 1,\n}\n\nexport class MarkdownString implements IMarkdownString {\n\n\tpublic value: string;\n\tpublic isTrusted?: boolean | MarkdownStringTrustedOptions;\n\tpublic supportThemeIcons?: boolean;\n\tpublic supportHtml?: boolean;\n\tpublic supportAlertSyntax?: boolean;\n\tpublic baseUri?: URI;\n\tpublic uris?: { [href: string]: UriComponents } | undefined;\n\n\tconstructor(\n\t\tvalue: string = '',\n\t\tisTrustedOrOptions: boolean | { isTrusted?: boolean | MarkdownStringTrustedOptions; supportThemeIcons?: boolean; supportHtml?: boolean; supportAlertSyntax?: boolean } = false,\n\t) {\n\t\tthis.value = value;\n\t\tif (typeof this.value !== 'string') {\n\t\t\tthrow illegalArgument('value');\n\t\t}\n\n\t\tif (typeof isTrustedOrOptions === 'boolean') {\n\t\t\tthis.isTrusted = isTrustedOrOptions;\n\t\t\tthis.supportThemeIcons = false;\n\t\t\tthis.supportHtml = false;\n\t\t\tthis.supportAlertSyntax = false;\n\t\t}\n\t\telse {\n\t\t\tthis.isTrusted = isTrustedOrOptions.isTrusted ?? undefined;\n\t\t\tthis.supportThemeIcons = isTrustedOrOptions.supportThemeIcons ?? false;\n\t\t\tthis.supportHtml = isTrustedOrOptions.supportHtml ?? false;\n\t\t\tthis.supportAlertSyntax = isTrustedOrOptions.supportAlertSyntax ?? false;\n\t\t}\n\t}\n\n\tappendText(value: string, newlineStyle: MarkdownStringTextNewlineStyle = MarkdownStringTextNewlineStyle.Paragraph): MarkdownString {\n\t\tthis.value += escapeMarkdownSyntaxTokens(this.supportThemeIcons ? escapeIcons(value) : value) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/([ \\t]+)/g, (_match, g1) => '&nbsp;'.repeat(g1.length)) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\>/gm, '\\\\>') // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\\\\n' : '\\n\\n'); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\n\t\treturn this;\n\t}\n\n\tappendMarkdown(value: string): MarkdownString {\n\t\tthis.value += value;\n\t\treturn this;\n\t}\n\n\tappendCodeblock(langId: string, code: string): MarkdownString {\n\t\tthis.value += `\\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\\n`;\n\t\treturn this;\n\t}\n\n\tappendLink(target: URI | string, label: string, title?: string): MarkdownString {\n\t\tthis.value += '[';\n\t\tthis.value += this._escape(label, ']');\n\t\tthis.value += '](';\n\t\tthis.value += this._escape(String(target), ')');\n\t\tif (title) {\n\t\t\tthis.value += ` \"${this._escape(this._escape(title, '\"'), ')')}\"`;\n\t\t}\n\t\tthis.value += ')';\n\t\treturn this;\n\t}\n\n\tprivate _escape(value: string, ch: string): string {\n\t\tconst r = new RegExp(escapeRegExpCharacters(ch), 'g');\n\t\treturn value.replace(r, (match, offset) => {\n\t\t\tif (value.charAt(offset - 1) !== '\\\\') {\n\t\t\t\treturn `\\\\${match}`;\n\t\t\t} else {\n\t\t\t\treturn match;\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport function isEmptyMarkdownString(oneOrMany: IMarkdownString | IMarkdownString[] | null | undefined): boolean {\n\tif (isMarkdownString(oneOrMany)) {\n\t\treturn !oneOrMany.value;\n\t} else if (Array.isArray(oneOrMany)) {\n\t\treturn oneOrMany.every(isEmptyMarkdownString);\n\t} else {\n\t\treturn true;\n\t}\n}\n\nexport function isMarkdownString(thing: unknown): thing is IMarkdownString {\n\tif (thing instanceof MarkdownString) {\n\t\treturn true;\n\t} else if (thing && typeof thing === 'object') {\n\t\treturn typeof (<IMarkdownString>thing).value === 'string'\n\t\t\t&& (typeof (<IMarkdownString>thing).isTrusted === 'boolean' || typeof (<IMarkdownString>thing).isTrusted === 'object' || (<IMarkdownString>thing).isTrusted === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportThemeIcons === 'boolean' || (<IMarkdownString>thing).supportThemeIcons === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportAlertSyntax === 'boolean' || (<IMarkdownString>thing).supportAlertSyntax === undefined);\n\t}\n\treturn false;\n}\n\nexport function markdownStringEqual(a: IMarkdownString, b: IMarkdownString): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t} else if (!a || !b) {\n\t\treturn false;\n\t} else {\n\t\treturn a.value === b.value\n\t\t\t&& a.isTrusted === b.isTrusted\n\t\t\t&& a.supportThemeIcons === b.supportThemeIcons\n\t\t\t&& a.supportHtml === b.supportHtml\n\t\t\t&& a.supportAlertSyntax === b.supportAlertSyntax\n\t\t\t&& (a.baseUri === b.baseUri || !!a.baseUri && !!b.baseUri && isEqual(URI.from(a.baseUri), URI.from(b.baseUri)));\n\t}\n}\n\nexport function escapeMarkdownSyntaxTokens(text: string): string {\n\t// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\n\treturn text\n\t\t.replace(/[\\\\`*_{}[\\]()#+!~]/g, '\\\\$&') // CodeQL [SM02383] Backslash is escaped in the character class\n\t\t.replace(/^([ \\t]*)-/gm, '$1\\\\-'); // CodeQL [SM02383] Backslash is escaped in the character class\n}\n\n/**\n * @see https://github.com/microsoft/vscode/issues/193746\n */\nexport function appendEscapedMarkdownCodeBlockFence(code: string, langId: string) {\n\tconst longestFenceLength =\n\t\tcode.match(/^`+/gm)?.reduce((a, b) => (a.length > b.length ? a : b)).length ??\n\t\t0;\n\tconst desiredFenceLength =\n\t\tlongestFenceLength >= 3 ? longestFenceLength + 1 : 3;\n\n\t// the markdown result\n\treturn [\n\t\t`${'`'.repeat(desiredFenceLength)}${langId}`,\n\t\tcode,\n\t\t`${'`'.repeat(desiredFenceLength)}`,\n\t].join('\\n');\n}\n\nexport function escapeDoubleQuotes(input: string) {\n\treturn input.replace(/\"/g, '&quot;');\n}\n\nexport function removeMarkdownEscapes(text: string): string {\n\tif (!text) {\n\t\treturn text;\n\t}\n\treturn text.replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!~])/g, '$1');\n}\n\nexport function parseHrefAndDimensions(href: string): { href: string; dimensions: string[] } {\n\tconst dimensions: string[] = [];\n\tconst splitted = href.split('|').map(s => s.trim());\n\thref = splitted[0];\n\tconst parameters = splitted[1];\n\tif (parameters) {\n\t\tconst heightFromParams = /height=(\\d+)/.exec(parameters);\n\t\tconst widthFromParams = /width=(\\d+)/.exec(parameters);\n\t\tconst height = heightFromParams ? heightFromParams[1] : '';\n\t\tconst width = widthFromParams ? widthFromParams[1] : '';\n\t\tconst widthIsFinite = isFinite(parseInt(width));\n\t\tconst heightIsFinite = isFinite(parseInt(height));\n\t\tif (widthIsFinite) {\n\t\t\tdimensions.push(`width=\"${width}\"`);\n\t\t}\n\t\tif (heightIsFinite) {\n\t\t\tdimensions.push(`height=\"${height}\"`);\n\t\t}\n\t}\n\treturn { href, dimensions };\n}\n\n/**\n * Resolves a Markdown link or media destination against the Markdown's base URI, as the Markdown\n * renderer does. Destinations with a scheme are returned unchanged.\n */\nexport function resolveWithBaseUri(baseUri: URI, href: string): string {\n\tconst hasScheme = /^\\w[\\w\\d+.-]*:/.test(href);\n\tif (hasScheme) {\n\t\treturn href;\n\t}\n\n\tif (baseUri.path.endsWith('/')) {\n\t\treturn resolvePath(baseUri, href).toString();\n\t} else {\n\t\treturn resolvePath(dirname(baseUri), href).toString();\n\t}\n}\n\nexport function createCommandUri(commandId: string, ...commandArgs: unknown[]): URI {\n\treturn URI.from({\n\t\tscheme: Schemas.command,\n\t\tpath: commandId,\n\t\tquery: commandArgs.length ? encodeURIComponent(JSON.stringify(commandArgs)) : undefined,\n\t});\n}\n\n/**\n * VS Code addresses some content with placeholder `http` URLs whose authority is wrapped in\n * underscores, such as `http://_vscodecontentref_/0`. Underscores are illegal in hostnames, so\n * no real site collides with this shape.\n */\nconst placeholderAuthority = /^https?:\\/\\/_[^/?#]*_(?:[/?#]|$)/i;\n\n/** Whether a target still resolves once content is copied into another application. */\nexport function isPortableLinkTarget(target: string): boolean {\n\tconst trimmed = target.trim();\n\treturn matchesSomeScheme(trimmed, Schemas.http, Schemas.https, Schemas.mailto)\n\t\t&& !placeholderAuthority.test(trimmed);\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { illegalArgument } from './errors.js';\nimport { escapeIcons } from './iconLabels.js';\nimport { matchesSomeScheme, Schemas } from './network.js';\nimport { dirname, isEqual, resolvePath } from './resources.js';\nimport { escapeRegExpCharacters } from './strings.js';\nimport { URI, UriComponents } from './uri.js';\n\nexport interface MarkdownStringTrustedOptions {\n\treadonly enabledCommands: readonly string[];\n}\n\nexport interface IMarkdownString {\n\treadonly value: string;\n\treadonly isTrusted?: boolean | MarkdownStringTrustedOptions;\n\treadonly supportThemeIcons?: boolean;\n\treadonly supportHtml?: boolean;\n\t/** @internal */\n\treadonly supportAlertSyntax?: boolean;\n\treadonly baseUri?: UriComponents;\n\turis?: { [href: string]: UriComponents };\n}\n\nexport const enum MarkdownStringTextNewlineStyle {\n\tParagraph = 0,\n\tBreak = 1,\n}\n\nexport class MarkdownString implements IMarkdownString {\n\n\tpublic value: string;\n\tpublic isTrusted?: boolean | MarkdownStringTrustedOptions;\n\tpublic supportThemeIcons?: boolean;\n\tpublic supportHtml?: boolean;\n\tpublic supportAlertSyntax?: boolean;\n\tpublic baseUri?: URI;\n\tpublic uris?: { [href: string]: UriComponents } | undefined;\n\n\tconstructor(\n\t\tvalue: string = '',\n\t\tisTrustedOrOptions: boolean | { isTrusted?: boolean | MarkdownStringTrustedOptions; supportThemeIcons?: boolean; supportHtml?: boolean; supportAlertSyntax?: boolean } = false,\n\t) {\n\t\tthis.value = value;\n\t\tif (typeof this.value !== 'string') {\n\t\t\tthrow illegalArgument('value');\n\t\t}\n\n\t\tif (typeof isTrustedOrOptions === 'boolean') {\n\t\t\tthis.isTrusted = isTrustedOrOptions;\n\t\t\tthis.supportThemeIcons = false;\n\t\t\tthis.supportHtml = false;\n\t\t\tthis.supportAlertSyntax = false;\n\t\t}\n\t\telse {\n\t\t\tthis.isTrusted = isTrustedOrOptions.isTrusted ?? undefined;\n\t\t\tthis.supportThemeIcons = isTrustedOrOptions.supportThemeIcons ?? false;\n\t\t\tthis.supportHtml = isTrustedOrOptions.supportHtml ?? false;\n\t\t\tthis.supportAlertSyntax = isTrustedOrOptions.supportAlertSyntax ?? false;\n\t\t}\n\t}\n\n\tappendText(value: string, newlineStyle: MarkdownStringTextNewlineStyle = MarkdownStringTextNewlineStyle.Paragraph): MarkdownString {\n\t\tthis.value += escapeMarkdownSyntaxTokens(this.supportThemeIcons ? escapeIcons(value) : value) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/([ \\t]+)/g, (_match, g1) => '&nbsp;'.repeat(g1.length)) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\>/gm, '\\\\>') // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\\\\n' : '\\n\\n'); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\n\t\treturn this;\n\t}\n\n\tappendMarkdown(value: string): MarkdownString {\n\t\tthis.value += value;\n\t\treturn this;\n\t}\n\n\tappendCodeblock(langId: string, code: string): MarkdownString {\n\t\tthis.value += `\\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\\n`;\n\t\treturn this;\n\t}\n\n\tappendLink(target: URI | string, label: string, title?: string): MarkdownString {\n\t\tthis.value += '[';\n\t\tthis.value += this._escape(label, ']');\n\t\tthis.value += '](';\n\t\tthis.value += this._escape(String(target), ')');\n\t\tif (title) {\n\t\t\tthis.value += ` \"${this._escape(this._escape(title, '\"'), ')')}\"`;\n\t\t}\n\t\tthis.value += ')';\n\t\treturn this;\n\t}\n\n\tprivate _escape(value: string, ch: string): string {\n\t\tconst r = new RegExp(escapeRegExpCharacters(ch), 'g');\n\t\treturn value.replace(r, (match, offset) => {\n\t\t\tif (value.charAt(offset - 1) !== '\\\\') {\n\t\t\t\treturn `\\\\${match}`;\n\t\t\t} else {\n\t\t\t\treturn match;\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport function isEmptyMarkdownString(oneOrMany: IMarkdownString | IMarkdownString[] | null | undefined): boolean {\n\tif (isMarkdownString(oneOrMany)) {\n\t\treturn !oneOrMany.value;\n\t} else if (Array.isArray(oneOrMany)) {\n\t\treturn oneOrMany.every(isEmptyMarkdownString);\n\t} else {\n\t\treturn true;\n\t}\n}\n\nexport function isMarkdownString(thing: unknown): thing is IMarkdownString {\n\tif (thing instanceof MarkdownString) {\n\t\treturn true;\n\t} else if (thing && typeof thing === 'object') {\n\t\treturn typeof (<IMarkdownString>thing).value === 'string'\n\t\t\t&& (typeof (<IMarkdownString>thing).isTrusted === 'boolean' || typeof (<IMarkdownString>thing).isTrusted === 'object' || (<IMarkdownString>thing).isTrusted === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportThemeIcons === 'boolean' || (<IMarkdownString>thing).supportThemeIcons === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportAlertSyntax === 'boolean' || (<IMarkdownString>thing).supportAlertSyntax === undefined);\n\t}\n\treturn false;\n}\n\nexport function markdownStringEqual(a: IMarkdownString, b: IMarkdownString): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t} else if (!a || !b) {\n\t\treturn false;\n\t} else {\n\t\treturn a.value === b.value\n\t\t\t&& a.isTrusted === b.isTrusted\n\t\t\t&& a.supportThemeIcons === b.supportThemeIcons\n\t\t\t&& a.supportHtml === b.supportHtml\n\t\t\t&& a.supportAlertSyntax === b.supportAlertSyntax\n\t\t\t&& (a.baseUri === b.baseUri || !!a.baseUri && !!b.baseUri && isEqual(URI.from(a.baseUri), URI.from(b.baseUri)));\n\t}\n}\n\nexport function escapeMarkdownSyntaxTokens(text: string): string {\n\t// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\n\treturn text\n\t\t.replace(/[\\\\`*_{}[\\]()#+!~]/g, '\\\\$&') // CodeQL [SM02383] Backslash is escaped in the character class\n\t\t.replace(/^([ \\t]*)-/gm, '$1\\\\-'); // CodeQL [SM02383] Backslash is escaped in the character class\n}\n\n/**\n * @see https://github.com/microsoft/vscode/issues/193746\n */\nexport function appendEscapedMarkdownCodeBlockFence(code: string, langId: string) {\n\tconst longestFenceLength =\n\t\tcode.match(/^`+/gm)?.reduce((a, b) => (a.length > b.length ? a : b)).length ??\n\t\t0;\n\tconst desiredFenceLength =\n\t\tlongestFenceLength >= 3 ? longestFenceLength + 1 : 3;\n\n\t// the markdown result\n\treturn [\n\t\t`${'`'.repeat(desiredFenceLength)}${langId}`,\n\t\tcode,\n\t\t`${'`'.repeat(desiredFenceLength)}`,\n\t].join('\\n');\n}\n\nexport function escapeDoubleQuotes(input: string) {\n\treturn input.replace(/\"/g, '&quot;');\n}\n\nexport function removeMarkdownEscapes(text: string): string {\n\tif (!text) {\n\t\treturn text;\n\t}\n\treturn text.replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!~])/g, '$1');\n}\n\nexport function parseHrefAndDimensions(href: string): { href: string; dimensions: string[] } {\n\tconst dimensions: string[] = [];\n\tconst splitted = href.split('|').map(s => s.trim());\n\thref = splitted[0];\n\tconst parameters = splitted[1];\n\tif (parameters) {\n\t\tconst heightFromParams = /height=(\\d+)/.exec(parameters);\n\t\tconst widthFromParams = /width=(\\d+)/.exec(parameters);\n\t\tconst height = heightFromParams ? heightFromParams[1] : '';\n\t\tconst width = widthFromParams ? widthFromParams[1] : '';\n\t\tconst widthIsFinite = isFinite(parseInt(width));\n\t\tconst heightIsFinite = isFinite(parseInt(height));\n\t\tif (widthIsFinite) {\n\t\t\tdimensions.push(`width=\"${width}\"`);\n\t\t}\n\t\tif (heightIsFinite) {\n\t\t\tdimensions.push(`height=\"${height}\"`);\n\t\t}\n\t}\n\treturn { href, dimensions };\n}\n\n/**\n * Resolves a Markdown link or media destination against the Markdown's base URI, as the Markdown\n * renderer does. Destinations with a scheme are returned unchanged.\n */\nexport function resolveWithBaseUri(baseUri: URI, href: string): string {\n\tconst hasScheme = /^\\w[\\w\\d+.-]*:/.test(href);\n\tif (hasScheme) {\n\t\treturn href;\n\t}\n\n\tif (baseUri.path.endsWith('/')) {\n\t\treturn resolvePath(baseUri, href).toString();\n\t} else {\n\t\treturn resolvePath(dirname(baseUri), href).toString();\n\t}\n}\n\nexport function createCommandUri(commandId: string, ...commandArgs: unknown[]): URI {\n\treturn URI.from({\n\t\tscheme: Schemas.command,\n\t\tpath: commandId,\n\t\tquery: commandArgs.length ? encodeURIComponent(JSON.stringify(commandArgs)) : undefined,\n\t});\n}\n\n/**\n * VS Code addresses some content with placeholder `http` URLs whose authority is wrapped in\n * underscores, such as `http://_vscodecontentref_/0`. Underscores are illegal in hostnames, so\n * no real site collides with this shape.\n */\nconst placeholderAuthority = /^https?:\\/\\/_[^/?#]*_(?:[/?#]|$)/i;\n\n/** Whether a target still resolves once content is copied into another application. */\nexport function isPortableLinkTarget(target: string): boolean {\n\tconst trimmed = target.trim();\n\treturn matchesSomeScheme(trimmed, Schemas.http, Schemas.https, Schemas.mailto)\n\t\t&& !placeholderAuthority.test(trimmed);\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/base/common/htmlContent.ts","vs/base/common/htmlContent.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,GAAG,EAAiB,MAAM,UAAU,CAAC;AAsB9C,MAAM,OAAO,cAAc;IAU1B,YACC,QAAgB,EAAE,EAClB,qBAAyK,KAAK;QAE9K,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,eAAe,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,IAAI,OAAO,kBAAkB,KAAK,SAAS,EAAE,CAAC;YAC7C,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC;YACpC,IAAI,CAAC,iBAAiB,GAAG,KAAK,CAAC;YAC/B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;YACzB,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;QACjC,CAAC;aACI,CAAC;YACL,IAAI,CAAC,SAAS,GAAG,kBAAkB,CAAC,SAAS,IAAI,SAAS,CAAC;YAC3D,IAAI,CAAC,iBAAiB,GAAG,k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AAC;QACf,MAAM,EAAE,OAAO,CAAC,OAAO;QACvB,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACvF,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AAEjE,uFAAuF;AACvF,MAAM,UAAU,oBAAoB,CAAC,MAAc;IAClD,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IAC9B,OAAO,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;WAC1E,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC","file":"htmlContent.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { illegalArgument } from './errors.js';\nimport { escapeIcons } from './iconLabels.js';\nimport { matchesSomeScheme, Schemas } from './network.js';\nimport { dirname, isEqual, resolvePath } from './resources.js';\nimport { URI, UriComponents } from './uri.js';\n\nexport interface MarkdownStringTrustedOptions {\n\treadonly enabledCommands: readonly string[];\n}\n\nexport interface IMarkdownString {\n\treadonly value: string;\n\treadonly isTrusted?: boolean | MarkdownStringTrustedOptions;\n\treadonly supportThemeIcons?: boolean;\n\treadonly supportHtml?: boolean;\n\t/** @internal */\n\treadonly supportAlertSyntax?: boolean;\n\treadonly baseUri?: UriComponents;\n\turis?: { [href: string]: UriComponents };\n}\n\nexport const enum MarkdownStringTextNewlineStyle {\n\tParagraph = 0,\n\tBreak = 1,\n}\n\nexport class MarkdownString implements IMarkdownString {\n\n\tpublic value: string;\n\tpublic isTrusted?: boolean | MarkdownStringTrustedOptions;\n\tpublic supportThemeIcons?: boolean;\n\tpublic supportHtml?: boolean;\n\tpublic supportAlertSyntax?: boolean;\n\tpublic baseUri?: URI;\n\tpublic uris?: { [href: string]: UriComponents } | undefined;\n\n\tconstructor(\n\t\tvalue: string = '',\n\t\tisTrustedOrOptions: boolean | { isTrusted?: boolean | MarkdownStringTrustedOptions; supportThemeIcons?: boolean; supportHtml?: boolean; supportAlertSyntax?: boolean } = false,\n\t) {\n\t\tthis.value = value;\n\t\tif (typeof this.value !== 'string') {\n\t\t\tthrow illegalArgument('value');\n\t\t}\n\n\t\tif (typeof isTrustedOrOptions === 'boolean') {\n\t\t\tthis.isTrusted = isTrustedOrOptions;\n\t\t\tthis.supportThemeIcons = false;\n\t\t\tthis.supportHtml = false;\n\t\t\tthis.supportAlertSyntax = false;\n\t\t}\n\t\telse {\n\t\t\tthis.isTrusted = isTrustedOrOptions.isTrusted ?? undefined;\n\t\t\tthis.supportThemeIcons = isTrustedOrOptions.supportThemeIcons ?? false;\n\t\t\tthis.supportHtml = isTrustedOrOptions.supportHtml ?? false;\n\t\t\tthis.supportAlertSyntax = isTrustedOrOptions.supportAlertSyntax ?? false;\n\t\t}\n\t}\n\n\tappendText(value: string, newlineStyle: MarkdownStringTextNewlineStyle = MarkdownStringTextNewlineStyle.Paragraph): MarkdownString {\n\t\tthis.value += escapeMarkdownSyntaxTokens(this.supportThemeIcons ? escapeIcons(value) : value) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/([ \\t]+)/g, (_match, g1) => '&nbsp;'.repeat(g1.length)) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\>/gm, '\\\\>') // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\\\\n' : '\\n\\n'); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\n\t\treturn this;\n\t}\n\n\tappendMarkdown(value: string): MarkdownString {\n\t\tthis.value += value;\n\t\treturn this;\n\t}\n\n\tappendCodeblock(langId: string, code: string): MarkdownString {\n\t\tthis.value += `\\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\\n`;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends a link.\n\t *\n\t * @param target The link target, used literally: it cannot end the link or add Markdown.\n\t * It is not validated, so check the scheme of untrusted targets before using them in trusted Markdown.\n\t * @param label The link text as Markdown. Use {@link escapeMarkdownLinkLabel} for plain text.\n\t * @param title The link title, used literally.\n\t */\n\tappendLink(target: URI | string, label: string, title?: string): MarkdownString {\n\t\tthis.value += '[';\n\t\tthis.value += this._escape(label, ']');\n\t\tthis.value += '](';\n\t\tthis.value += escapeMarkdownLinkDestination(String(target));\n\t\tif (title) {\n\t\t\tthis.value += ` \"${escapeMarkdownLinkTitle(title)}\"`;\n\t\t}\n\t\tthis.value += ')';\n\t\treturn this;\n\t}\n\n\tprivate _escape(value: string, ch: string): string {\n\t\t// A delimiter is already escaped only if it follows an odd number of backslashes:\n\t\t// in `\\\\]` the first backslash escapes the second one, which leaves `]` unescaped.\n\t\t// A trailing odd run of backslashes is completed as well, so that it cannot escape\n\t\t// the delimiter that is appended after the value.\n\t\tlet result = '';\n\t\tlet backslashes = 0;\n\t\tfor (const c of value) {\n\t\t\tif (c === ch && backslashes % 2 === 0) {\n\t\t\t\tresult += '\\\\';\n\t\t\t}\n\t\t\tbackslashes = c === '\\\\' ? backslashes + 1 : 0;\n\t\t\tresult += c;\n\t\t}\n\t\treturn backslashes % 2 === 1 ? result + '\\\\' : result;\n\t}\n}\n\n/**\n * Escapes a string for use as a Markdown link destination: whitespace and control characters,\n * which would end the destination, are percent-encoded and Markdown syntax is backslash-escaped.\n */\nfunction escapeMarkdownLinkDestination(target: string): string {\n\treturn target\n\t\t.replace(/[\\s\\x00-\\x1f\\x7f]/g, ch => encodeURIComponent(ch))\n\t\t.replace(/[\\\\()<>]/g, '\\\\$&');\n}\n\n/**\n * Escapes a string for use as a double-quoted Markdown link title. Line breaks are replaced,\n * because an empty line would end the paragraph and with it the link. Characters that the\n * Markdown parser interprets in titles are written as character references, not backslash\n * escapes: marked reads `\\\\\"` as an escaped quote, so a title ending in a backslash would\n * otherwise extend into the following text.\n */\nfunction escapeMarkdownLinkTitle(title: string): string {\n\treturn title\n\t\t.replace(/\\r\\n|[\\r\\n]/g, ' ')\n\t\t.replace(/\\0/g, '\\uFFFD') // HTML cannot represent NUL\n\t\t.replace(/[&\\\\\"()\\t]/g, ch => `&#${ch.charCodeAt(0)};`);\n}\n\nexport function isEmptyMarkdownString(oneOrMany: IMarkdownString | IMarkdownString[] | null | undefined): boolean {\n\tif (isMarkdownString(oneOrMany)) {\n\t\treturn !oneOrMany.value;\n\t} else if (Array.isArray(oneOrMany)) {\n\t\treturn oneOrMany.every(isEmptyMarkdownString);\n\t} else {\n\t\treturn true;\n\t}\n}\n\nexport function isMarkdownString(thing: unknown): thing is IMarkdownString {\n\tif (thing instanceof MarkdownString) {\n\t\treturn true;\n\t} else if (thing && typeof thing === 'object') {\n\t\treturn typeof (<IMarkdownString>thing).value === 'string'\n\t\t\t&& (typeof (<IMarkdownString>thing).isTrusted === 'boolean' || typeof (<IMarkdownString>thing).isTrusted === 'object' || (<IMarkdownString>thing).isTrusted === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportThemeIcons === 'boolean' || (<IMarkdownString>thing).supportThemeIcons === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportAlertSyntax === 'boolean' || (<IMarkdownString>thing).supportAlertSyntax === undefined);\n\t}\n\treturn false;\n}\n\nexport function markdownStringEqual(a: IMarkdownString, b: IMarkdownString): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t} else if (!a || !b) {\n\t\treturn false;\n\t} else {\n\t\treturn a.value === b.value\n\t\t\t&& a.isTrusted === b.isTrusted\n\t\t\t&& a.supportThemeIcons === b.supportThemeIcons\n\t\t\t&& a.supportHtml === b.supportHtml\n\t\t\t&& a.supportAlertSyntax === b.supportAlertSyntax\n\t\t\t&& (a.baseUri === b.baseUri || !!a.baseUri && !!b.baseUri && isEqual(URI.from(a.baseUri), URI.from(b.baseUri)));\n\t}\n}\n\nexport function escapeMarkdownSyntaxTokens(text: string): string {\n\t// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\n\treturn text\n\t\t.replace(/[\\\\`*_{}[\\]()#+!~]/g, '\\\\$&') // CodeQL [SM02383] Backslash is escaped in the character class\n\t\t.replace(/^([ \\t]*)-/gm, '$1\\\\-'); // CodeQL [SM02383] Backslash is escaped in the character class\n}\n\n/**\n * Escapes plain text for use as the text of a Markdown link, for example the label of\n * {@link MarkdownString.appendLink}, so that it renders literally. Unlike\n * {@link escapeMarkdownLinkLabel}, this also prevents autolinks, emphasis, code spans and\n * character references: every ASCII punctuation character is backslash-escaped. Line breaks\n * are replaced with spaces, because an empty line would end the paragraph and with it the link.\n */\nexport function escapeMarkdownLinkText(text: string): string {\n\treturn text\n\t\t.replace(/\\r\\n|[\\r\\n]/g, ' ')\n\t\t.replace(/[!-/:-@[-`{-~]/g, '\\\\$&'); // CodeQL [SM02383] All ASCII punctuation, including the backslash, is escaped\n}\n\n/**\n * @see https://github.com/microsoft/vscode/issues/193746\n */\nexport function appendEscapedMarkdownCodeBlockFence(code: string, langId: string) {\n\tconst longestFenceLength =\n\t\tcode.match(/^`+/gm)?.reduce((a, b) => (a.length > b.length ? a : b)).length ??\n\t\t0;\n\tconst desiredFenceLength =\n\t\tlongestFenceLength >= 3 ? longestFenceLength + 1 : 3;\n\n\t// the markdown result\n\treturn [\n\t\t`${'`'.repeat(desiredFenceLength)}${langId}`,\n\t\tcode,\n\t\t`${'`'.repeat(desiredFenceLength)}`,\n\t].join('\\n');\n}\n\nexport function escapeDoubleQuotes(input: string) {\n\treturn input.replace(/\"/g, '&quot;');\n}\n\nexport function removeMarkdownEscapes(text: string): string {\n\tif (!text) {\n\t\treturn text;\n\t}\n\treturn text.replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!~])/g, '$1');\n}\n\nexport function parseHrefAndDimensions(href: string): { href: string; dimensions: string[] } {\n\tconst dimensions: string[] = [];\n\tconst splitted = href.split('|').map(s => s.trim());\n\thref = splitted[0];\n\tconst parameters = splitted[1];\n\tif (parameters) {\n\t\tconst heightFromParams = /height=(\\d+)/.exec(parameters);\n\t\tconst widthFromParams = /width=(\\d+)/.exec(parameters);\n\t\tconst height = heightFromParams ? heightFromParams[1] : '';\n\t\tconst width = widthFromParams ? widthFromParams[1] : '';\n\t\tconst widthIsFinite = isFinite(parseInt(width));\n\t\tconst heightIsFinite = isFinite(parseInt(height));\n\t\tif (widthIsFinite) {\n\t\t\tdimensions.push(`width=\"${width}\"`);\n\t\t}\n\t\tif (heightIsFinite) {\n\t\t\tdimensions.push(`height=\"${height}\"`);\n\t\t}\n\t}\n\treturn { href, dimensions };\n}\n\n/**\n * Resolves a Markdown link or media destination against the Markdown's base URI, as the Markdown\n * renderer does. Destinations with a scheme are returned unchanged.\n */\nexport function resolveWithBaseUri(baseUri: URI, href: string): string {\n\tconst hasScheme = /^\\w[\\w\\d+.-]*:/.test(href);\n\tif (hasScheme) {\n\t\treturn href;\n\t}\n\n\tif (baseUri.path.endsWith('/')) {\n\t\treturn resolvePath(baseUri, href).toString();\n\t} else {\n\t\treturn resolvePath(dirname(baseUri), href).toString();\n\t}\n}\n\nexport function createCommandUri(commandId: string, ...commandArgs: unknown[]): URI {\n\treturn URI.from({\n\t\tscheme: Schemas.command,\n\t\tpath: commandId,\n\t\tquery: commandArgs.length ? encodeURIComponent(JSON.stringify(commandArgs)) : undefined,\n\t});\n}\n\n/**\n * VS Code addresses some content with placeholder `http` URLs whose authority is wrapped in\n * underscores, such as `http://_vscodecontentref_/0`. Underscores are illegal in hostnames, so\n * no real site collides with this shape.\n */\nconst placeholderAuthority = /^https?:\\/\\/_[^/?#]*_(?:[/?#]|$)/i;\n\n/** Whether a target still resolves once content is copied into another application. */\nexport function isPortableLinkTarget(target: string): boolean {\n\tconst trimmed = target.trim();\n\treturn matchesSomeScheme(trimmed, Schemas.http, Schemas.https, Schemas.mailto)\n\t\t&& !placeholderAuthority.test(trimmed);\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport { illegalArgument } from './errors.js';\nimport { escapeIcons } from './iconLabels.js';\nimport { matchesSomeScheme, Schemas } from './network.js';\nimport { dirname, isEqual, resolvePath } from './resources.js';\nimport { URI, UriComponents } from './uri.js';\n\nexport interface MarkdownStringTrustedOptions {\n\treadonly enabledCommands: readonly string[];\n}\n\nexport interface IMarkdownString {\n\treadonly value: string;\n\treadonly isTrusted?: boolean | MarkdownStringTrustedOptions;\n\treadonly supportThemeIcons?: boolean;\n\treadonly supportHtml?: boolean;\n\t/** @internal */\n\treadonly supportAlertSyntax?: boolean;\n\treadonly baseUri?: UriComponents;\n\turis?: { [href: string]: UriComponents };\n}\n\nexport const enum MarkdownStringTextNewlineStyle {\n\tParagraph = 0,\n\tBreak = 1,\n}\n\nexport class MarkdownString implements IMarkdownString {\n\n\tpublic value: string;\n\tpublic isTrusted?: boolean | MarkdownStringTrustedOptions;\n\tpublic supportThemeIcons?: boolean;\n\tpublic supportHtml?: boolean;\n\tpublic supportAlertSyntax?: boolean;\n\tpublic baseUri?: URI;\n\tpublic uris?: { [href: string]: UriComponents } | undefined;\n\n\tconstructor(\n\t\tvalue: string = '',\n\t\tisTrustedOrOptions: boolean | { isTrusted?: boolean | MarkdownStringTrustedOptions; supportThemeIcons?: boolean; supportHtml?: boolean; supportAlertSyntax?: boolean } = false,\n\t) {\n\t\tthis.value = value;\n\t\tif (typeof this.value !== 'string') {\n\t\t\tthrow illegalArgument('value');\n\t\t}\n\n\t\tif (typeof isTrustedOrOptions === 'boolean') {\n\t\t\tthis.isTrusted = isTrustedOrOptions;\n\t\t\tthis.supportThemeIcons = false;\n\t\t\tthis.supportHtml = false;\n\t\t\tthis.supportAlertSyntax = false;\n\t\t}\n\t\telse {\n\t\t\tthis.isTrusted = isTrustedOrOptions.isTrusted ?? undefined;\n\t\t\tthis.supportThemeIcons = isTrustedOrOptions.supportThemeIcons ?? false;\n\t\t\tthis.supportHtml = isTrustedOrOptions.supportHtml ?? false;\n\t\t\tthis.supportAlertSyntax = isTrustedOrOptions.supportAlertSyntax ?? false;\n\t\t}\n\t}\n\n\tappendText(value: string, newlineStyle: MarkdownStringTextNewlineStyle = MarkdownStringTextNewlineStyle.Paragraph): MarkdownString {\n\t\tthis.value += escapeMarkdownSyntaxTokens(this.supportThemeIcons ? escapeIcons(value) : value) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/([ \\t]+)/g, (_match, g1) => '&nbsp;'.repeat(g1.length)) // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\>/gm, '\\\\>') // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\t\t\t.replace(/\\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\\\\n' : '\\n\\n'); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.\n\n\t\treturn this;\n\t}\n\n\tappendMarkdown(value: string): MarkdownString {\n\t\tthis.value += value;\n\t\treturn this;\n\t}\n\n\tappendCodeblock(langId: string, code: string): MarkdownString {\n\t\tthis.value += `\\n${appendEscapedMarkdownCodeBlockFence(code, langId)}\\n`;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Appends a link.\n\t *\n\t * @param target The link target, used literally: it cannot end the link or add Markdown.\n\t * It is not validated, so check the scheme of untrusted targets before using them in trusted Markdown.\n\t * @param label The link text as Markdown. Use {@link escapeMarkdownLinkLabel} for plain text.\n\t * @param title The link title, used literally.\n\t */\n\tappendLink(target: URI | string, label: string, title?: string): MarkdownString {\n\t\tthis.value += '[';\n\t\tthis.value += this._escape(label, ']');\n\t\tthis.value += '](';\n\t\tthis.value += escapeMarkdownLinkDestination(String(target));\n\t\tif (title) {\n\t\t\tthis.value += ` \"${escapeMarkdownLinkTitle(title)}\"`;\n\t\t}\n\t\tthis.value += ')';\n\t\treturn this;\n\t}\n\n\tprivate _escape(value: string, ch: string): string {\n\t\t// A delimiter is already escaped only if it follows an odd number of backslashes:\n\t\t// in `\\\\]` the first backslash escapes the second one, which leaves `]` unescaped.\n\t\t// A trailing odd run of backslashes is completed as well, so that it cannot escape\n\t\t// the delimiter that is appended after the value.\n\t\tlet result = '';\n\t\tlet backslashes = 0;\n\t\tfor (const c of value) {\n\t\t\tif (c === ch && backslashes % 2 === 0) {\n\t\t\t\tresult += '\\\\';\n\t\t\t}\n\t\t\tbackslashes = c === '\\\\' ? backslashes + 1 : 0;\n\t\t\tresult += c;\n\t\t}\n\t\treturn backslashes % 2 === 1 ? result + '\\\\' : result;\n\t}\n}\n\n/**\n * Escapes a string for use as a Markdown link destination: whitespace and control characters,\n * which would end the destination, are percent-encoded and Markdown syntax is backslash-escaped.\n */\nfunction escapeMarkdownLinkDestination(target: string): string {\n\treturn target\n\t\t.replace(/[\\s\\x00-\\x1f\\x7f]/g, ch => encodeURIComponent(ch))\n\t\t.replace(/[\\\\()<>]/g, '\\\\$&');\n}\n\n/**\n * Escapes a string for use as a double-quoted Markdown link title. Line breaks are replaced,\n * because an empty line would end the paragraph and with it the link. Characters that the\n * Markdown parser interprets in titles are written as character references, not backslash\n * escapes: marked reads `\\\\\"` as an escaped quote, so a title ending in a backslash would\n * otherwise extend into the following text.\n */\nfunction escapeMarkdownLinkTitle(title: string): string {\n\treturn title\n\t\t.replace(/\\r\\n|[\\r\\n]/g, ' ')\n\t\t.replace(/\\0/g, '\\uFFFD') // HTML cannot represent NUL\n\t\t.replace(/[&\\\\\"()\\t]/g, ch => `&#${ch.charCodeAt(0)};`);\n}\n\nexport function isEmptyMarkdownString(oneOrMany: IMarkdownString | IMarkdownString[] | null | undefined): boolean {\n\tif (isMarkdownString(oneOrMany)) {\n\t\treturn !oneOrMany.value;\n\t} else if (Array.isArray(oneOrMany)) {\n\t\treturn oneOrMany.every(isEmptyMarkdownString);\n\t} else {\n\t\treturn true;\n\t}\n}\n\nexport function isMarkdownString(thing: unknown): thing is IMarkdownString {\n\tif (thing instanceof MarkdownString) {\n\t\treturn true;\n\t} else if (thing && typeof thing === 'object') {\n\t\treturn typeof (<IMarkdownString>thing).value === 'string'\n\t\t\t&& (typeof (<IMarkdownString>thing).isTrusted === 'boolean' || typeof (<IMarkdownString>thing).isTrusted === 'object' || (<IMarkdownString>thing).isTrusted === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportThemeIcons === 'boolean' || (<IMarkdownString>thing).supportThemeIcons === undefined)\n\t\t\t&& (typeof (<IMarkdownString>thing).supportAlertSyntax === 'boolean' || (<IMarkdownString>thing).supportAlertSyntax === undefined);\n\t}\n\treturn false;\n}\n\nexport function markdownStringEqual(a: IMarkdownString, b: IMarkdownString): boolean {\n\tif (a === b) {\n\t\treturn true;\n\t} else if (!a || !b) {\n\t\treturn false;\n\t} else {\n\t\treturn a.value === b.value\n\t\t\t&& a.isTrusted === b.isTrusted\n\t\t\t&& a.supportThemeIcons === b.supportThemeIcons\n\t\t\t&& a.supportHtml === b.supportHtml\n\t\t\t&& a.supportAlertSyntax === b.supportAlertSyntax\n\t\t\t&& (a.baseUri === b.baseUri || !!a.baseUri && !!b.baseUri && isEqual(URI.from(a.baseUri), URI.from(b.baseUri)));\n\t}\n}\n\nexport function escapeMarkdownSyntaxTokens(text: string): string {\n\t// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\n\treturn text\n\t\t.replace(/[\\\\`*_{}[\\]()#+!~]/g, '\\\\$&') // CodeQL [SM02383] Backslash is escaped in the character class\n\t\t.replace(/^([ \\t]*)-/gm, '$1\\\\-'); // CodeQL [SM02383] Backslash is escaped in the character class\n}\n\n/**\n * Escapes plain text for use as the text of a Markdown link, for example the label of\n * {@link MarkdownString.appendLink}, so that it renders literally. Unlike\n * {@link escapeMarkdownLinkLabel}, this also prevents autolinks, emphasis, code spans and\n * character references: every ASCII punctuation character is backslash-escaped. Line breaks\n * are replaced with spaces, because an empty line would end the paragraph and with it the link.\n */\nexport function escapeMarkdownLinkText(text: string): string {\n\treturn text\n\t\t.replace(/\\r\\n|[\\r\\n]/g, ' ')\n\t\t.replace(/[!-/:-@[-`{-~]/g, '\\\\$&'); // CodeQL [SM02383] All ASCII punctuation, including the backslash, is escaped\n}\n\n/**\n * @see https://github.com/microsoft/vscode/issues/193746\n */\nexport function appendEscapedMarkdownCodeBlockFence(code: string, langId: string) {\n\tconst longestFenceLength =\n\t\tcode.match(/^`+/gm)?.reduce((a, b) => (a.length > b.length ? a : b)).length ??\n\t\t0;\n\tconst desiredFenceLength =\n\t\tlongestFenceLength >= 3 ? longestFenceLength + 1 : 3;\n\n\t// the markdown result\n\treturn [\n\t\t`${'`'.repeat(desiredFenceLength)}${langId}`,\n\t\tcode,\n\t\t`${'`'.repeat(desiredFenceLength)}`,\n\t].join('\\n');\n}\n\nexport function escapeDoubleQuotes(input: string) {\n\treturn input.replace(/\"/g, '&quot;');\n}\n\nexport function removeMarkdownEscapes(text: string): string {\n\tif (!text) {\n\t\treturn text;\n\t}\n\treturn text.replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!~])/g, '$1');\n}\n\nexport function parseHrefAndDimensions(href: string): { href: string; dimensions: string[] } {\n\tconst dimensions: string[] = [];\n\tconst splitted = href.split('|').map(s => s.trim());\n\thref = splitted[0];\n\tconst parameters = splitted[1];\n\tif (parameters) {\n\t\tconst heightFromParams = /height=(\\d+)/.exec(parameters);\n\t\tconst widthFromParams = /width=(\\d+)/.exec(parameters);\n\t\tconst height = heightFromParams ? heightFromParams[1] : '';\n\t\tconst width = widthFromParams ? widthFromParams[1] : '';\n\t\tconst widthIsFinite = isFinite(parseInt(width));\n\t\tconst heightIsFinite = isFinite(parseInt(height));\n\t\tif (widthIsFinite) {\n\t\t\tdimensions.push(`width=\"${width}\"`);\n\t\t}\n\t\tif (heightIsFinite) {\n\t\t\tdimensions.push(`height=\"${height}\"`);\n\t\t}\n\t}\n\treturn { href, dimensions };\n}\n\n/**\n * Resolves a Markdown link or media destination against the Markdown's base URI, as the Markdown\n * renderer does. Destinations with a scheme are returned unchanged.\n */\nexport function resolveWithBaseUri(baseUri: URI, href: string): string {\n\tconst hasScheme = /^\\w[\\w\\d+.-]*:/.test(href);\n\tif (hasScheme) {\n\t\treturn href;\n\t}\n\n\tif (baseUri.path.endsWith('/')) {\n\t\treturn resolvePath(baseUri, href).toString();\n\t} else {\n\t\treturn resolvePath(dirname(baseUri), href).toString();\n\t}\n}\n\nexport function createCommandUri(commandId: string, ...commandArgs: unknown[]): URI {\n\treturn URI.from({\n\t\tscheme: Schemas.command,\n\t\tpath: commandId,\n\t\tquery: commandArgs.length ? encodeURIComponent(JSON.stringify(commandArgs)) : undefined,\n\t});\n}\n\n/**\n * VS Code addresses some content with placeholder `http` URLs whose authority is wrapped in\n * underscores, such as `http://_vscodecontentref_/0`. Underscores are illegal in hostnames, so\n * no real site collides with this shape.\n */\nconst placeholderAuthority = /^https?:\\/\\/_[^/?#]*_(?:[/?#]|$)/i;\n\n/** Whether a target still resolves once content is copied into another application. */\nexport function isPortableLinkTarget(target: string): boolean {\n\tconst trimmed = target.trim();\n\treturn matchesSomeScheme(trimmed, Schemas.http, Schemas.https, Schemas.mailto)\n\t\t&& !placeholderAuthority.test(trimmed);\n}\n"]}
@@ -231,6 +231,7 @@ let OpenerService = class OpenerService {
231
231
  sourceHref: target.sourceHref,
232
232
  preferredOpenerId,
233
233
  viewColumn: options?.openToSide ? ViewColumn.Beside : undefined,
234
+ sourceWindowId: options?.sourceWindowId,
234
235
  }, CancellationToken.None);
235
236
  if (didOpen) {
236
237
  return true;
@@ -1 +1 @@
1
- {"version":3,"sources":["file:///mnt/vss/_work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vB,WAAA,kBAAkB,CAAA;IAClB,WAAA,eAAe,CAAA;GAfL,aAAa,CAgLzB","file":"openerService.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport * as dom from '../../../base/browser/dom.js';\nimport { mainWindow } from '../../../base/browser/window.js';\nimport { CancellationToken } from '../../../base/common/cancellation.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { LinkedList } from '../../../base/common/linkedList.js';\nimport { ResourceMap } from '../../../base/common/map.js';\nimport { parse } from '../../../base/common/marshalling.js';\nimport { matchesScheme, matchesSomeScheme, Schemas } from '../../../base/common/network.js';\nimport { normalizePath } from '../../../base/common/resources.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { ICodeEditorService } from './codeEditorService.js';\nimport { ICommandService } from '../../../platform/commands/common/commands.js';\nimport { EditorOpenSource, ViewColumn } from '../../../platform/editor/common/editor.js';\nimport { defaultExternalUriOpenerId, extractSelection, IExternalOpener, IExternalUriResolver, IOpener, IOpenerService, IResolvedExternalUri, IValidator, OpenOptions, ResolveExternalUriOptions } from '../../../platform/opener/common/opener.js';\n\ninterface IExternalUriOpenTarget {\n\treadonly sourceUri: URI;\n\treadonly sourceHref: string;\n\treadonly href: string;\n\treadonly validationTarget: URI | string;\n}\n\nclass CommandOpener implements IOpener {\n\n\tconstructor(@ICommandService private readonly _commandService: ICommandService) { }\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tif (!matchesScheme(target, Schemas.command)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!options?.allowCommands) {\n\t\t\t// silently ignore commands when command-links are disabled, also\n\t\t\t// suppress other openers by returning TRUE\n\t\t\treturn true;\n\t\t}\n\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tif (Array.isArray(options.allowCommands)) {\n\t\t\t// Only allow specific commands\n\t\t\tif (!options.allowCommands.includes(target.path)) {\n\t\t\t\t// Suppress other openers by returning TRUE\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// execute as command\n\t\tlet args: unknown[] = [];\n\t\ttry {\n\t\t\targs = parse(decodeURIComponent(target.query));\n\t\t} catch {\n\t\t\t// ignore and retry\n\t\t\ttry {\n\t\t\t\targs = parse(target.query);\n\t\t\t} catch {\n\t\t\t\t// ignore error\n\t\t\t}\n\t\t}\n\t\tif (!Array.isArray(args)) {\n\t\t\targs = [args];\n\t\t}\n\t\tawait this._commandService.executeCommand(target.path, ...args);\n\t\treturn true;\n\t}\n}\n\nclass EditorOpener implements IOpener {\n\n\tconstructor(@ICodeEditorService private readonly _editorService: ICodeEditorService) { }\n\n\tasync open(target: URI | string, options: OpenOptions) {\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tconst { selection, uri } = extractSelection(target);\n\t\ttarget = uri;\n\n\t\tif (target.scheme === Schemas.file) {\n\t\t\ttarget = normalizePath(target); // workaround for non-normalized paths (https://github.com/microsoft/vscode/issues/12954)\n\t\t}\n\n\t\tawait this._editorService.openCodeEditor(\n\t\t\t{\n\t\t\t\tresource: target,\n\t\t\t\toptions: {\n\t\t\t\t\tselection,\n\t\t\t\t\tsource: options?.fromUserGesture ? EditorOpenSource.USER : EditorOpenSource.API,\n\t\t\t\t\t...options?.editorOptions\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis._editorService.getFocusedCodeEditor(),\n\t\t\toptions?.openToSide\n\t\t);\n\n\t\treturn true;\n\t}\n}\n\nfunction shouldOpenExternal(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.openExternal || matchesSomeScheme(target, Schemas.mailto, Schemas.http, Schemas.https, Schemas.vsls);\n}\n\nfunction shouldUseContributedExternalOpeners(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.allowContributedOpeners\n\t\t&& options.allowContributedOpeners !== defaultExternalUriOpenerId\n\t\t&& shouldOpenExternal(target, options);\n}\n\nexport class OpenerService implements IOpenerService {\n\n\tdeclare readonly _serviceBrand: undefined;\n\n\tprivate readonly _openers = new LinkedList<IOpener>();\n\tprivate readonly _validators = new LinkedList<IValidator>();\n\tprivate readonly _resolvers = new LinkedList<IExternalUriResolver>();\n\tprivate readonly _resolvedUriTargets = new ResourceMap<URI>(uri => uri.with({ path: null, fragment: null, query: null }).toString());\n\n\tprivate _defaultExternalOpener: IExternalOpener;\n\tprivate readonly _externalOpeners = new LinkedList<IExternalOpener>();\n\tprivate readonly _externalResourceOpener: IOpener;\n\n\tconstructor(\n\t\t@ICodeEditorService editorService: ICodeEditorService,\n\t\t@ICommandService commandService: ICommandService\n\t) {\n\t\t// Default external opener is going through window.open()\n\t\tthis._defaultExternalOpener = {\n\t\t\topenExternal: async href => {\n\t\t\t\t// ensure to open HTTP/HTTPS links into new windows\n\t\t\t\t// to not trigger a navigation. Any other link is\n\t\t\t\t// safe to be set as HREF to prevent a blank window\n\t\t\t\t// from opening.\n\t\t\t\tif (matchesSomeScheme(href, Schemas.http, Schemas.https)) {\n\t\t\t\t\tdom.windowOpenNoOpener(href);\n\t\t\t\t} else {\n\t\t\t\t\tmainWindow.location.href = href;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\n\t\t// Default opener: any external, maito, http(s), command, and catch-all-editors\n\t\tthis._externalResourceOpener = {\n\t\t\topen: async (target: URI | string, options?: OpenOptions) => {\n\t\t\t\tif (shouldOpenExternal(target, options)) {\n\t\t\t\t\t// open externally\n\t\t\t\t\tawait this._doOpenExternal(target, options);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\tthis._openers.push(this._externalResourceOpener);\n\t\tthis._openers.push(new CommandOpener(commandService));\n\t\tthis._openers.push(new EditorOpener(editorService));\n\t}\n\n\tregisterOpener(opener: IOpener): IDisposable {\n\t\tconst remove = this._openers.unshift(opener);\n\t\treturn { dispose: remove };\n\t}\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tconst targetURI = typeof target === 'string' ? URI.parse(target) : target;\n\n\t\t// Internal schemes are not openable and must instead be handled in event listeners\n\t\tif (targetURI.scheme === Schemas.internal) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet externalUriOpenTarget: IExternalUriOpenTarget | undefined;\n\t\tif (shouldUseContributedExternalOpeners(target, options)) {\n\t\t\texternalUriOpenTarget = await this._resolveExternalUriOpenTarget(target, options);\n\t\t\tif (await this._openWithContributedExternalOpeners(externalUriOpenTarget, options)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!options?.skipValidation) {\n\t\t\tconst validationTarget = externalUriOpenTarget?.validationTarget ?? this._resolvedUriTargets.get(targetURI) ?? target;\n\t\t\tif (!(await this._validate(validationTarget, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// check with contributed openers\n\t\tfor (const opener of this._openers) {\n\t\t\tif (externalUriOpenTarget && opener === this._externalResourceOpener) {\n\t\t\t\treturn this._openDefaultExternal(externalUriOpenTarget);\n\t\t\t}\n\t\t\tconst handled = await opener.open(target, options);\n\t\t\tif (handled) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tasync resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri> {\n\t\tfor (const resolver of this._resolvers) {\n\t\t\ttry {\n\t\t\t\tconst result = await resolver.resolveExternalUri(resource, options);\n\t\t\t\tif (result) {\n\t\t\t\t\tif (!this._resolvedUriTargets.has(result.resolved)) {\n\t\t\t\t\t\tthis._resolvedUriTargets.set(result.resolved, resource);\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error('Could not resolve external URI: ' + resource.toString());\n\t}\n\n\tprivate async _resolveExternalUriOpenTarget(resource: URI | string, options: OpenOptions | undefined): Promise<IExternalUriOpenTarget> {\n\t\t//todo@jrieken IExternalUriResolver should support `uri: URI | string`\n\t\tconst uri = typeof resource === 'string' ? URI.parse(resource) : resource;\n\t\tlet externalUri: URI;\n\n\t\ttry {\n\t\t\texternalUri = (await this.resolveExternalUri(uri, options)).resolved;\n\t\t} catch {\n\t\t\texternalUri = uri;\n\t\t}\n\n\t\tconst preserveOriginalString = typeof resource === 'string' && uri.toString() === externalUri.toString();\n\t\tlet href: string;\n\t\tif (preserveOriginalString) {\n\t\t\t// open the url-string AS IS\n\t\t\thref = resource;\n\t\t} else {\n\t\t\t// open URI using the toString(noEncode)+encodeURI-trick\n\t\t\thref = encodeURI(externalUri.toString(true));\n\t\t}\n\n\t\treturn {\n\t\t\tsourceUri: uri,\n\t\t\tsourceHref: typeof resource === 'string' ? resource : uri.toString(true),\n\t\t\thref,\n\t\t\tvalidationTarget: preserveOriginalString ? resource : externalUri,\n\t\t};\n\t}\n\n\tprivate async _openWithContributedExternalOpeners(target: IExternalUriOpenTarget, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst preferredOpenerId = typeof options?.allowContributedOpeners === 'string' ? options.allowContributedOpeners : undefined;\n\t\tfor (const opener of this._externalOpeners) {\n\t\t\tconst didOpen = await opener.openExternal(target.href, {\n\t\t\t\tsourceUri: target.sourceUri,\n\t\t\t\tsourceHref: target.sourceHref,\n\t\t\t\tpreferredOpenerId,\n\t\t\t\tviewColumn: options?.openToSide ? ViewColumn.Beside : undefined,\n\t\t\t}, CancellationToken.None);\n\t\t\tif (didOpen) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate _openDefaultExternal(target: IExternalUriOpenTarget): Promise<boolean> {\n\t\treturn this._defaultExternalOpener.openExternal(target.href, { sourceUri: target.sourceUri, sourceHref: target.sourceHref }, CancellationToken.None);\n\t}\n\n\tprivate async _doOpenExternal(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst target = await this._resolveExternalUriOpenTarget(resource, options);\n\t\treturn this._openDefaultExternal(target);\n\t}\n\n\tprivate async _validate(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tfor (const validator of this._validators) {\n\t\t\tif (!(await validator.shouldOpen(resource, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose() {\n\t\tthis._validators.clear();\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport * as dom from '../../../base/browser/dom.js';\nimport { mainWindow } from '../../../base/browser/window.js';\nimport { CancellationToken } from '../../../base/common/cancellation.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { LinkedList } from '../../../base/common/linkedList.js';\nimport { ResourceMap } from '../../../base/common/map.js';\nimport { parse } from '../../../base/common/marshalling.js';\nimport { matchesScheme, matchesSomeScheme, Schemas } from '../../../base/common/network.js';\nimport { normalizePath } from '../../../base/common/resources.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { ICodeEditorService } from './codeEditorService.js';\nimport { ICommandService } from '../../../platform/commands/common/commands.js';\nimport { EditorOpenSource, ViewColumn } from '../../../platform/editor/common/editor.js';\nimport { defaultExternalUriOpenerId, extractSelection, IExternalOpener, IExternalUriResolver, IOpener, IOpenerService, IResolvedExternalUri, IValidator, OpenOptions, ResolveExternalUriOptions } from '../../../platform/opener/common/opener.js';\n\ninterface IExternalUriOpenTarget {\n\treadonly sourceUri: URI;\n\treadonly sourceHref: string;\n\treadonly href: string;\n\treadonly validationTarget: URI | string;\n}\n\nclass CommandOpener implements IOpener {\n\n\tconstructor(@ICommandService private readonly _commandService: ICommandService) { }\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tif (!matchesScheme(target, Schemas.command)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!options?.allowCommands) {\n\t\t\t// silently ignore commands when command-links are disabled, also\n\t\t\t// suppress other openers by returning TRUE\n\t\t\treturn true;\n\t\t}\n\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tif (Array.isArray(options.allowCommands)) {\n\t\t\t// Only allow specific commands\n\t\t\tif (!options.allowCommands.includes(target.path)) {\n\t\t\t\t// Suppress other openers by returning TRUE\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// execute as command\n\t\tlet args: unknown[] = [];\n\t\ttry {\n\t\t\targs = parse(decodeURIComponent(target.query));\n\t\t} catch {\n\t\t\t// ignore and retry\n\t\t\ttry {\n\t\t\t\targs = parse(target.query);\n\t\t\t} catch {\n\t\t\t\t// ignore error\n\t\t\t}\n\t\t}\n\t\tif (!Array.isArray(args)) {\n\t\t\targs = [args];\n\t\t}\n\t\tawait this._commandService.executeCommand(target.path, ...args);\n\t\treturn true;\n\t}\n}\n\nclass EditorOpener implements IOpener {\n\n\tconstructor(@ICodeEditorService private readonly _editorService: ICodeEditorService) { }\n\n\tasync open(target: URI | string, options: OpenOptions) {\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tconst { selection, uri } = extractSelection(target);\n\t\ttarget = uri;\n\n\t\tif (target.scheme === Schemas.file) {\n\t\t\ttarget = normalizePath(target); // workaround for non-normalized paths (https://github.com/microsoft/vscode/issues/12954)\n\t\t}\n\n\t\tawait this._editorService.openCodeEditor(\n\t\t\t{\n\t\t\t\tresource: target,\n\t\t\t\toptions: {\n\t\t\t\t\tselection,\n\t\t\t\t\tsource: options?.fromUserGesture ? EditorOpenSource.USER : EditorOpenSource.API,\n\t\t\t\t\t...options?.editorOptions\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis._editorService.getFocusedCodeEditor(),\n\t\t\toptions?.openToSide\n\t\t);\n\n\t\treturn true;\n\t}\n}\n\nfunction shouldOpenExternal(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.openExternal || matchesSomeScheme(target, Schemas.mailto, Schemas.http, Schemas.https, Schemas.vsls);\n}\n\nfunction shouldUseContributedExternalOpeners(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.allowContributedOpeners\n\t\t&& options.allowContributedOpeners !== defaultExternalUriOpenerId\n\t\t&& shouldOpenExternal(target, options);\n}\n\nexport class OpenerService implements IOpenerService {\n\n\tdeclare readonly _serviceBrand: undefined;\n\n\tprivate readonly _openers = new LinkedList<IOpener>();\n\tprivate readonly _validators = new LinkedList<IValidator>();\n\tprivate readonly _resolvers = new LinkedList<IExternalUriResolver>();\n\tprivate readonly _resolvedUriTargets = new ResourceMap<URI>(uri => uri.with({ path: null, fragment: null, query: null }).toString());\n\n\tprivate _defaultExternalOpener: IExternalOpener;\n\tprivate readonly _externalOpeners = new LinkedList<IExternalOpener>();\n\tprivate readonly _externalResourceOpener: IOpener;\n\n\tconstructor(\n\t\t@ICodeEditorService editorService: ICodeEditorService,\n\t\t@ICommandService commandService: ICommandService\n\t) {\n\t\t// Default external opener is going through window.open()\n\t\tthis._defaultExternalOpener = {\n\t\t\topenExternal: async href => {\n\t\t\t\t// ensure to open HTTP/HTTPS links into new windows\n\t\t\t\t// to not trigger a navigation. Any other link is\n\t\t\t\t// safe to be set as HREF to prevent a blank window\n\t\t\t\t// from opening.\n\t\t\t\tif (matchesSomeScheme(href, Schemas.http, Schemas.https)) {\n\t\t\t\t\tdom.windowOpenNoOpener(href);\n\t\t\t\t} else {\n\t\t\t\t\tmainWindow.location.href = href;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\n\t\t// Default opener: any external, maito, http(s), command, and catch-all-editors\n\t\tthis._externalResourceOpener = {\n\t\t\topen: async (target: URI | string, options?: OpenOptions) => {\n\t\t\t\tif (shouldOpenExternal(target, options)) {\n\t\t\t\t\t// open externally\n\t\t\t\t\tawait this._doOpenExternal(target, options);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\tthis._openers.push(this._externalResourceOpener);\n\t\tthis._openers.push(new CommandOpener(commandService));\n\t\tthis._openers.push(new EditorOpener(editorService));\n\t}\n\n\tregisterOpener(opener: IOpener): IDisposable {\n\t\tconst remove = this._openers.unshift(opener);\n\t\treturn { dispose: remove };\n\t}\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tconst targetURI = typeof target === 'string' ? URI.parse(target) : target;\n\n\t\t// Internal schemes are not openable and must instead be handled in event listeners\n\t\tif (targetURI.scheme === Schemas.internal) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet externalUriOpenTarget: IExternalUriOpenTarget | undefined;\n\t\tif (shouldUseContributedExternalOpeners(target, options)) {\n\t\t\texternalUriOpenTarget = await this._resolveExternalUriOpenTarget(target, options);\n\t\t\tif (await this._openWithContributedExternalOpeners(externalUriOpenTarget, options)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!options?.skipValidation) {\n\t\t\tconst validationTarget = externalUriOpenTarget?.validationTarget ?? this._resolvedUriTargets.get(targetURI) ?? target;\n\t\t\tif (!(await this._validate(validationTarget, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// check with contributed openers\n\t\tfor (const opener of this._openers) {\n\t\t\tif (externalUriOpenTarget && opener === this._externalResourceOpener) {\n\t\t\t\treturn this._openDefaultExternal(externalUriOpenTarget);\n\t\t\t}\n\t\t\tconst handled = await opener.open(target, options);\n\t\t\tif (handled) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tasync resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri> {\n\t\tfor (const resolver of this._resolvers) {\n\t\t\ttry {\n\t\t\t\tconst result = await resolver.resolveExternalUri(resource, options);\n\t\t\t\tif (result) {\n\t\t\t\t\tif (!this._resolvedUriTargets.has(result.resolved)) {\n\t\t\t\t\t\tthis._resolvedUriTargets.set(result.resolved, resource);\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error('Could not resolve external URI: ' + resource.toString());\n\t}\n\n\tprivate async _resolveExternalUriOpenTarget(resource: URI | string, options: OpenOptions | undefined): Promise<IExternalUriOpenTarget> {\n\t\t//todo@jrieken IExternalUriResolver should support `uri: URI | string`\n\t\tconst uri = typeof resource === 'string' ? URI.parse(resource) : resource;\n\t\tlet externalUri: URI;\n\n\t\ttry {\n\t\t\texternalUri = (await this.resolveExternalUri(uri, options)).resolved;\n\t\t} catch {\n\t\t\texternalUri = uri;\n\t\t}\n\n\t\tconst preserveOriginalString = typeof resource === 'string' && uri.toString() === externalUri.toString();\n\t\tlet href: string;\n\t\tif (preserveOriginalString) {\n\t\t\t// open the url-string AS IS\n\t\t\thref = resource;\n\t\t} else {\n\t\t\t// open URI using the toString(noEncode)+encodeURI-trick\n\t\t\thref = encodeURI(externalUri.toString(true));\n\t\t}\n\n\t\treturn {\n\t\t\tsourceUri: uri,\n\t\t\tsourceHref: typeof resource === 'string' ? resource : uri.toString(true),\n\t\t\thref,\n\t\t\tvalidationTarget: preserveOriginalString ? resource : externalUri,\n\t\t};\n\t}\n\n\tprivate async _openWithContributedExternalOpeners(target: IExternalUriOpenTarget, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst preferredOpenerId = typeof options?.allowContributedOpeners === 'string' ? options.allowContributedOpeners : undefined;\n\t\tfor (const opener of this._externalOpeners) {\n\t\t\tconst didOpen = await opener.openExternal(target.href, {\n\t\t\t\tsourceUri: target.sourceUri,\n\t\t\t\tsourceHref: target.sourceHref,\n\t\t\t\tpreferredOpenerId,\n\t\t\t\tviewColumn: options?.openToSide ? ViewColumn.Beside : undefined,\n\t\t\t}, CancellationToken.None);\n\t\t\tif (didOpen) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate _openDefaultExternal(target: IExternalUriOpenTarget): Promise<boolean> {\n\t\treturn this._defaultExternalOpener.openExternal(target.href, { sourceUri: target.sourceUri, sourceHref: target.sourceHref }, CancellationToken.None);\n\t}\n\n\tprivate async _doOpenExternal(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst target = await this._resolveExternalUriOpenTarget(resource, options);\n\t\treturn this._openDefaultExternal(target);\n\t}\n\n\tprivate async _validate(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tfor (const validator of this._validators) {\n\t\t\tif (!(await validator.shouldOpen(resource, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose() {\n\t\tthis._validators.clear();\n\t}\n}\n"]}
1
+ {"version":3,"sources":["file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src/vs/editor/browser/services/openerService.ts","vs/editor/browser/services/openerService.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;;;;;;;;;;AAEhG,OAAO,KAAK,GAAG,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,M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EAAE,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,EAAE,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACtJ,CAAC;IAEO,KAAK,CAAC,eAAe,CAAC,QAAsB,EAAE,OAAgC;QACrF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,6BAA6B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEO,KAAK,CAAC,SAAS,CAAC,QAAsB,EAAE,OAAgC;QAC/E,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAC1C,IAAI,CAAC,CAAC,MAAM,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;gBACtD,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO;QACN,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACD,CAAA;AAjLY,aAAa;IAcvB,WAAA,kBAAkB,CAAA;IAClB,WAAA,eAAe,CAAA;GAfL,aAAa,CAiLzB","file":"openerService.js","sourceRoot":"file:///mnt/vss/_work/1/s/dependencies/vscode/out-editor-src","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport * as dom from '../../../base/browser/dom.js';\nimport { mainWindow } from '../../../base/browser/window.js';\nimport { CancellationToken } from '../../../base/common/cancellation.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { LinkedList } from '../../../base/common/linkedList.js';\nimport { ResourceMap } from '../../../base/common/map.js';\nimport { parse } from '../../../base/common/marshalling.js';\nimport { matchesScheme, matchesSomeScheme, Schemas } from '../../../base/common/network.js';\nimport { normalizePath } from '../../../base/common/resources.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { ICodeEditorService } from './codeEditorService.js';\nimport { ICommandService } from '../../../platform/commands/common/commands.js';\nimport { EditorOpenSource, ViewColumn } from '../../../platform/editor/common/editor.js';\nimport { defaultExternalUriOpenerId, extractSelection, IExternalOpener, IExternalUriResolver, IOpener, IOpenerService, IResolvedExternalUri, IValidator, OpenOptions, ResolveExternalUriOptions } from '../../../platform/opener/common/opener.js';\n\ninterface IExternalUriOpenTarget {\n\treadonly sourceUri: URI;\n\treadonly sourceHref: string;\n\treadonly href: string;\n\treadonly validationTarget: URI | string;\n}\n\nclass CommandOpener implements IOpener {\n\n\tconstructor(@ICommandService private readonly _commandService: ICommandService) { }\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tif (!matchesScheme(target, Schemas.command)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!options?.allowCommands) {\n\t\t\t// silently ignore commands when command-links are disabled, also\n\t\t\t// suppress other openers by returning TRUE\n\t\t\treturn true;\n\t\t}\n\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tif (Array.isArray(options.allowCommands)) {\n\t\t\t// Only allow specific commands\n\t\t\tif (!options.allowCommands.includes(target.path)) {\n\t\t\t\t// Suppress other openers by returning TRUE\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// execute as command\n\t\tlet args: unknown[] = [];\n\t\ttry {\n\t\t\targs = parse(decodeURIComponent(target.query));\n\t\t} catch {\n\t\t\t// ignore and retry\n\t\t\ttry {\n\t\t\t\targs = parse(target.query);\n\t\t\t} catch {\n\t\t\t\t// ignore error\n\t\t\t}\n\t\t}\n\t\tif (!Array.isArray(args)) {\n\t\t\targs = [args];\n\t\t}\n\t\tawait this._commandService.executeCommand(target.path, ...args);\n\t\treturn true;\n\t}\n}\n\nclass EditorOpener implements IOpener {\n\n\tconstructor(@ICodeEditorService private readonly _editorService: ICodeEditorService) { }\n\n\tasync open(target: URI | string, options: OpenOptions) {\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tconst { selection, uri } = extractSelection(target);\n\t\ttarget = uri;\n\n\t\tif (target.scheme === Schemas.file) {\n\t\t\ttarget = normalizePath(target); // workaround for non-normalized paths (https://github.com/microsoft/vscode/issues/12954)\n\t\t}\n\n\t\tawait this._editorService.openCodeEditor(\n\t\t\t{\n\t\t\t\tresource: target,\n\t\t\t\toptions: {\n\t\t\t\t\tselection,\n\t\t\t\t\tsource: options?.fromUserGesture ? EditorOpenSource.USER : EditorOpenSource.API,\n\t\t\t\t\t...options?.editorOptions\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis._editorService.getFocusedCodeEditor(),\n\t\t\toptions?.openToSide\n\t\t);\n\n\t\treturn true;\n\t}\n}\n\nfunction shouldOpenExternal(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.openExternal || matchesSomeScheme(target, Schemas.mailto, Schemas.http, Schemas.https, Schemas.vsls);\n}\n\nfunction shouldUseContributedExternalOpeners(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.allowContributedOpeners\n\t\t&& options.allowContributedOpeners !== defaultExternalUriOpenerId\n\t\t&& shouldOpenExternal(target, options);\n}\n\nexport class OpenerService implements IOpenerService {\n\n\tdeclare readonly _serviceBrand: undefined;\n\n\tprivate readonly _openers = new LinkedList<IOpener>();\n\tprivate readonly _validators = new LinkedList<IValidator>();\n\tprivate readonly _resolvers = new LinkedList<IExternalUriResolver>();\n\tprivate readonly _resolvedUriTargets = new ResourceMap<URI>(uri => uri.with({ path: null, fragment: null, query: null }).toString());\n\n\tprivate _defaultExternalOpener: IExternalOpener;\n\tprivate readonly _externalOpeners = new LinkedList<IExternalOpener>();\n\tprivate readonly _externalResourceOpener: IOpener;\n\n\tconstructor(\n\t\t@ICodeEditorService editorService: ICodeEditorService,\n\t\t@ICommandService commandService: ICommandService\n\t) {\n\t\t// Default external opener is going through window.open()\n\t\tthis._defaultExternalOpener = {\n\t\t\topenExternal: async href => {\n\t\t\t\t// ensure to open HTTP/HTTPS links into new windows\n\t\t\t\t// to not trigger a navigation. Any other link is\n\t\t\t\t// safe to be set as HREF to prevent a blank window\n\t\t\t\t// from opening.\n\t\t\t\tif (matchesSomeScheme(href, Schemas.http, Schemas.https)) {\n\t\t\t\t\tdom.windowOpenNoOpener(href);\n\t\t\t\t} else {\n\t\t\t\t\tmainWindow.location.href = href;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\n\t\t// Default opener: any external, maito, http(s), command, and catch-all-editors\n\t\tthis._externalResourceOpener = {\n\t\t\topen: async (target: URI | string, options?: OpenOptions) => {\n\t\t\t\tif (shouldOpenExternal(target, options)) {\n\t\t\t\t\t// open externally\n\t\t\t\t\tawait this._doOpenExternal(target, options);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\tthis._openers.push(this._externalResourceOpener);\n\t\tthis._openers.push(new CommandOpener(commandService));\n\t\tthis._openers.push(new EditorOpener(editorService));\n\t}\n\n\tregisterOpener(opener: IOpener): IDisposable {\n\t\tconst remove = this._openers.unshift(opener);\n\t\treturn { dispose: remove };\n\t}\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tconst targetURI = typeof target === 'string' ? URI.parse(target) : target;\n\n\t\t// Internal schemes are not openable and must instead be handled in event listeners\n\t\tif (targetURI.scheme === Schemas.internal) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet externalUriOpenTarget: IExternalUriOpenTarget | undefined;\n\t\tif (shouldUseContributedExternalOpeners(target, options)) {\n\t\t\texternalUriOpenTarget = await this._resolveExternalUriOpenTarget(target, options);\n\t\t\tif (await this._openWithContributedExternalOpeners(externalUriOpenTarget, options)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!options?.skipValidation) {\n\t\t\tconst validationTarget = externalUriOpenTarget?.validationTarget ?? this._resolvedUriTargets.get(targetURI) ?? target;\n\t\t\tif (!(await this._validate(validationTarget, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// check with contributed openers\n\t\tfor (const opener of this._openers) {\n\t\t\tif (externalUriOpenTarget && opener === this._externalResourceOpener) {\n\t\t\t\treturn this._openDefaultExternal(externalUriOpenTarget);\n\t\t\t}\n\t\t\tconst handled = await opener.open(target, options);\n\t\t\tif (handled) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tasync resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri> {\n\t\tfor (const resolver of this._resolvers) {\n\t\t\ttry {\n\t\t\t\tconst result = await resolver.resolveExternalUri(resource, options);\n\t\t\t\tif (result) {\n\t\t\t\t\tif (!this._resolvedUriTargets.has(result.resolved)) {\n\t\t\t\t\t\tthis._resolvedUriTargets.set(result.resolved, resource);\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error('Could not resolve external URI: ' + resource.toString());\n\t}\n\n\tprivate async _resolveExternalUriOpenTarget(resource: URI | string, options: OpenOptions | undefined): Promise<IExternalUriOpenTarget> {\n\t\t//todo@jrieken IExternalUriResolver should support `uri: URI | string`\n\t\tconst uri = typeof resource === 'string' ? URI.parse(resource) : resource;\n\t\tlet externalUri: URI;\n\n\t\ttry {\n\t\t\texternalUri = (await this.resolveExternalUri(uri, options)).resolved;\n\t\t} catch {\n\t\t\texternalUri = uri;\n\t\t}\n\n\t\tconst preserveOriginalString = typeof resource === 'string' && uri.toString() === externalUri.toString();\n\t\tlet href: string;\n\t\tif (preserveOriginalString) {\n\t\t\t// open the url-string AS IS\n\t\t\thref = resource;\n\t\t} else {\n\t\t\t// open URI using the toString(noEncode)+encodeURI-trick\n\t\t\thref = encodeURI(externalUri.toString(true));\n\t\t}\n\n\t\treturn {\n\t\t\tsourceUri: uri,\n\t\t\tsourceHref: typeof resource === 'string' ? resource : uri.toString(true),\n\t\t\thref,\n\t\t\tvalidationTarget: preserveOriginalString ? resource : externalUri,\n\t\t};\n\t}\n\n\tprivate async _openWithContributedExternalOpeners(target: IExternalUriOpenTarget, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst preferredOpenerId = typeof options?.allowContributedOpeners === 'string' ? options.allowContributedOpeners : undefined;\n\t\tfor (const opener of this._externalOpeners) {\n\t\t\tconst didOpen = await opener.openExternal(target.href, {\n\t\t\t\tsourceUri: target.sourceUri,\n\t\t\t\tsourceHref: target.sourceHref,\n\t\t\t\tpreferredOpenerId,\n\t\t\t\tviewColumn: options?.openToSide ? ViewColumn.Beside : undefined,\n\t\t\t\tsourceWindowId: options?.sourceWindowId,\n\t\t\t}, CancellationToken.None);\n\t\t\tif (didOpen) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate _openDefaultExternal(target: IExternalUriOpenTarget): Promise<boolean> {\n\t\treturn this._defaultExternalOpener.openExternal(target.href, { sourceUri: target.sourceUri, sourceHref: target.sourceHref }, CancellationToken.None);\n\t}\n\n\tprivate async _doOpenExternal(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst target = await this._resolveExternalUriOpenTarget(resource, options);\n\t\treturn this._openDefaultExternal(target);\n\t}\n\n\tprivate async _validate(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tfor (const validator of this._validators) {\n\t\t\tif (!(await validator.shouldOpen(resource, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose() {\n\t\tthis._validators.clear();\n\t}\n}\n","/*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n\nimport * as dom from '../../../base/browser/dom.js';\nimport { mainWindow } from '../../../base/browser/window.js';\nimport { CancellationToken } from '../../../base/common/cancellation.js';\nimport { IDisposable } from '../../../base/common/lifecycle.js';\nimport { LinkedList } from '../../../base/common/linkedList.js';\nimport { ResourceMap } from '../../../base/common/map.js';\nimport { parse } from '../../../base/common/marshalling.js';\nimport { matchesScheme, matchesSomeScheme, Schemas } from '../../../base/common/network.js';\nimport { normalizePath } from '../../../base/common/resources.js';\nimport { URI } from '../../../base/common/uri.js';\nimport { ICodeEditorService } from './codeEditorService.js';\nimport { ICommandService } from '../../../platform/commands/common/commands.js';\nimport { EditorOpenSource, ViewColumn } from '../../../platform/editor/common/editor.js';\nimport { defaultExternalUriOpenerId, extractSelection, IExternalOpener, IExternalUriResolver, IOpener, IOpenerService, IResolvedExternalUri, IValidator, OpenOptions, ResolveExternalUriOptions } from '../../../platform/opener/common/opener.js';\n\ninterface IExternalUriOpenTarget {\n\treadonly sourceUri: URI;\n\treadonly sourceHref: string;\n\treadonly href: string;\n\treadonly validationTarget: URI | string;\n}\n\nclass CommandOpener implements IOpener {\n\n\tconstructor(@ICommandService private readonly _commandService: ICommandService) { }\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tif (!matchesScheme(target, Schemas.command)) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif (!options?.allowCommands) {\n\t\t\t// silently ignore commands when command-links are disabled, also\n\t\t\t// suppress other openers by returning TRUE\n\t\t\treturn true;\n\t\t}\n\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tif (Array.isArray(options.allowCommands)) {\n\t\t\t// Only allow specific commands\n\t\t\tif (!options.allowCommands.includes(target.path)) {\n\t\t\t\t// Suppress other openers by returning TRUE\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\t// execute as command\n\t\tlet args: unknown[] = [];\n\t\ttry {\n\t\t\targs = parse(decodeURIComponent(target.query));\n\t\t} catch {\n\t\t\t// ignore and retry\n\t\t\ttry {\n\t\t\t\targs = parse(target.query);\n\t\t\t} catch {\n\t\t\t\t// ignore error\n\t\t\t}\n\t\t}\n\t\tif (!Array.isArray(args)) {\n\t\t\targs = [args];\n\t\t}\n\t\tawait this._commandService.executeCommand(target.path, ...args);\n\t\treturn true;\n\t}\n}\n\nclass EditorOpener implements IOpener {\n\n\tconstructor(@ICodeEditorService private readonly _editorService: ICodeEditorService) { }\n\n\tasync open(target: URI | string, options: OpenOptions) {\n\t\tif (typeof target === 'string') {\n\t\t\ttarget = URI.parse(target);\n\t\t}\n\n\t\tconst { selection, uri } = extractSelection(target);\n\t\ttarget = uri;\n\n\t\tif (target.scheme === Schemas.file) {\n\t\t\ttarget = normalizePath(target); // workaround for non-normalized paths (https://github.com/microsoft/vscode/issues/12954)\n\t\t}\n\n\t\tawait this._editorService.openCodeEditor(\n\t\t\t{\n\t\t\t\tresource: target,\n\t\t\t\toptions: {\n\t\t\t\t\tselection,\n\t\t\t\t\tsource: options?.fromUserGesture ? EditorOpenSource.USER : EditorOpenSource.API,\n\t\t\t\t\t...options?.editorOptions\n\t\t\t\t}\n\t\t\t},\n\t\t\tthis._editorService.getFocusedCodeEditor(),\n\t\t\toptions?.openToSide\n\t\t);\n\n\t\treturn true;\n\t}\n}\n\nfunction shouldOpenExternal(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.openExternal || matchesSomeScheme(target, Schemas.mailto, Schemas.http, Schemas.https, Schemas.vsls);\n}\n\nfunction shouldUseContributedExternalOpeners(target: URI | string, options: OpenOptions | undefined): boolean {\n\treturn !!options?.allowContributedOpeners\n\t\t&& options.allowContributedOpeners !== defaultExternalUriOpenerId\n\t\t&& shouldOpenExternal(target, options);\n}\n\nexport class OpenerService implements IOpenerService {\n\n\tdeclare readonly _serviceBrand: undefined;\n\n\tprivate readonly _openers = new LinkedList<IOpener>();\n\tprivate readonly _validators = new LinkedList<IValidator>();\n\tprivate readonly _resolvers = new LinkedList<IExternalUriResolver>();\n\tprivate readonly _resolvedUriTargets = new ResourceMap<URI>(uri => uri.with({ path: null, fragment: null, query: null }).toString());\n\n\tprivate _defaultExternalOpener: IExternalOpener;\n\tprivate readonly _externalOpeners = new LinkedList<IExternalOpener>();\n\tprivate readonly _externalResourceOpener: IOpener;\n\n\tconstructor(\n\t\t@ICodeEditorService editorService: ICodeEditorService,\n\t\t@ICommandService commandService: ICommandService\n\t) {\n\t\t// Default external opener is going through window.open()\n\t\tthis._defaultExternalOpener = {\n\t\t\topenExternal: async href => {\n\t\t\t\t// ensure to open HTTP/HTTPS links into new windows\n\t\t\t\t// to not trigger a navigation. Any other link is\n\t\t\t\t// safe to be set as HREF to prevent a blank window\n\t\t\t\t// from opening.\n\t\t\t\tif (matchesSomeScheme(href, Schemas.http, Schemas.https)) {\n\t\t\t\t\tdom.windowOpenNoOpener(href);\n\t\t\t\t} else {\n\t\t\t\t\tmainWindow.location.href = href;\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\n\t\t// Default opener: any external, maito, http(s), command, and catch-all-editors\n\t\tthis._externalResourceOpener = {\n\t\t\topen: async (target: URI | string, options?: OpenOptions) => {\n\t\t\t\tif (shouldOpenExternal(target, options)) {\n\t\t\t\t\t// open externally\n\t\t\t\t\tawait this._doOpenExternal(target, options);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t\tthis._openers.push(this._externalResourceOpener);\n\t\tthis._openers.push(new CommandOpener(commandService));\n\t\tthis._openers.push(new EditorOpener(editorService));\n\t}\n\n\tregisterOpener(opener: IOpener): IDisposable {\n\t\tconst remove = this._openers.unshift(opener);\n\t\treturn { dispose: remove };\n\t}\n\n\tasync open(target: URI | string, options?: OpenOptions): Promise<boolean> {\n\t\tconst targetURI = typeof target === 'string' ? URI.parse(target) : target;\n\n\t\t// Internal schemes are not openable and must instead be handled in event listeners\n\t\tif (targetURI.scheme === Schemas.internal) {\n\t\t\treturn false;\n\t\t}\n\n\t\tlet externalUriOpenTarget: IExternalUriOpenTarget | undefined;\n\t\tif (shouldUseContributedExternalOpeners(target, options)) {\n\t\t\texternalUriOpenTarget = await this._resolveExternalUriOpenTarget(target, options);\n\t\t\tif (await this._openWithContributedExternalOpeners(externalUriOpenTarget, options)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\tif (!options?.skipValidation) {\n\t\t\tconst validationTarget = externalUriOpenTarget?.validationTarget ?? this._resolvedUriTargets.get(targetURI) ?? target;\n\t\t\tif (!(await this._validate(validationTarget, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\t// check with contributed openers\n\t\tfor (const opener of this._openers) {\n\t\t\tif (externalUriOpenTarget && opener === this._externalResourceOpener) {\n\t\t\t\treturn this._openDefaultExternal(externalUriOpenTarget);\n\t\t\t}\n\t\t\tconst handled = await opener.open(target, options);\n\t\t\tif (handled) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tasync resolveExternalUri(resource: URI, options?: ResolveExternalUriOptions): Promise<IResolvedExternalUri> {\n\t\tfor (const resolver of this._resolvers) {\n\t\t\ttry {\n\t\t\t\tconst result = await resolver.resolveExternalUri(resource, options);\n\t\t\t\tif (result) {\n\t\t\t\t\tif (!this._resolvedUriTargets.has(result.resolved)) {\n\t\t\t\t\t\tthis._resolvedUriTargets.set(result.resolved, resource);\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// noop\n\t\t\t}\n\t\t}\n\n\t\tthrow new Error('Could not resolve external URI: ' + resource.toString());\n\t}\n\n\tprivate async _resolveExternalUriOpenTarget(resource: URI | string, options: OpenOptions | undefined): Promise<IExternalUriOpenTarget> {\n\t\t//todo@jrieken IExternalUriResolver should support `uri: URI | string`\n\t\tconst uri = typeof resource === 'string' ? URI.parse(resource) : resource;\n\t\tlet externalUri: URI;\n\n\t\ttry {\n\t\t\texternalUri = (await this.resolveExternalUri(uri, options)).resolved;\n\t\t} catch {\n\t\t\texternalUri = uri;\n\t\t}\n\n\t\tconst preserveOriginalString = typeof resource === 'string' && uri.toString() === externalUri.toString();\n\t\tlet href: string;\n\t\tif (preserveOriginalString) {\n\t\t\t// open the url-string AS IS\n\t\t\thref = resource;\n\t\t} else {\n\t\t\t// open URI using the toString(noEncode)+encodeURI-trick\n\t\t\thref = encodeURI(externalUri.toString(true));\n\t\t}\n\n\t\treturn {\n\t\t\tsourceUri: uri,\n\t\t\tsourceHref: typeof resource === 'string' ? resource : uri.toString(true),\n\t\t\thref,\n\t\t\tvalidationTarget: preserveOriginalString ? resource : externalUri,\n\t\t};\n\t}\n\n\tprivate async _openWithContributedExternalOpeners(target: IExternalUriOpenTarget, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst preferredOpenerId = typeof options?.allowContributedOpeners === 'string' ? options.allowContributedOpeners : undefined;\n\t\tfor (const opener of this._externalOpeners) {\n\t\t\tconst didOpen = await opener.openExternal(target.href, {\n\t\t\t\tsourceUri: target.sourceUri,\n\t\t\t\tsourceHref: target.sourceHref,\n\t\t\t\tpreferredOpenerId,\n\t\t\t\tviewColumn: options?.openToSide ? ViewColumn.Beside : undefined,\n\t\t\t\tsourceWindowId: options?.sourceWindowId,\n\t\t\t}, CancellationToken.None);\n\t\t\tif (didOpen) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate _openDefaultExternal(target: IExternalUriOpenTarget): Promise<boolean> {\n\t\treturn this._defaultExternalOpener.openExternal(target.href, { sourceUri: target.sourceUri, sourceHref: target.sourceHref }, CancellationToken.None);\n\t}\n\n\tprivate async _doOpenExternal(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tconst target = await this._resolveExternalUriOpenTarget(resource, options);\n\t\treturn this._openDefaultExternal(target);\n\t}\n\n\tprivate async _validate(resource: URI | string, options: OpenOptions | undefined): Promise<boolean> {\n\t\tfor (const validator of this._validators) {\n\t\t\tif (!(await validator.shouldOpen(resource, options))) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n\n\tdispose() {\n\t\tthis._validators.clear();\n\t}\n}\n"]}
@@ -23,14 +23,17 @@ export class DefaultLinesDiffComputer {
23
23
  this.myersDiffingAlgorithm = new MyersDiffAlgorithm();
24
24
  }
25
25
  computeDiff(originalLines, modifiedLines, options) {
26
+ return this._computeDiff(originalLines, modifiedLines, options);
27
+ }
28
+ _computeDiff(originalLines, modifiedLines, options, rawChanges) {
26
29
  if (originalLines.length <= 1 && equals(originalLines, modifiedLines, (a, b) => a === b)) {
27
30
  return new LinesDiff([], [], false);
28
31
  }
29
32
  if (originalLines.length === 1 && originalLines[0].length === 0 || modifiedLines.length === 1 && modifiedLines[0].length === 0) {
33
+ const rangeMapping = new RangeMapping(new Range(1, 1, originalLines.length, originalLines[originalLines.length - 1].length + 1), new Range(1, 1, modifiedLines.length, modifiedLines[modifiedLines.length - 1].length + 1));
34
+ rawChanges?.push(rangeMapping);
30
35
  return new LinesDiff([
31
- new DetailedLineRangeMapping(new LineRange(1, originalLines.length + 1), new LineRange(1, modifiedLines.length + 1), [
32
- new RangeMapping(new Range(1, 1, originalLines.length, originalLines[originalLines.length - 1].length + 1), new Range(1, 1, modifiedLines.length, modifiedLines[modifiedLines.length - 1].length + 1))
33
- ])
36
+ new DetailedLineRangeMapping(new LineRange(1, originalLines.length + 1), new LineRange(1, modifiedLines.length + 1), [rangeMapping])
34
37
  ], [], false);
35
38
  }
36
39
  const timeout = options.maxComputationTimeMs === 0 ? InfiniteTimeout.instance : new DateTimeout(options.maxComputationTimeMs);
@@ -73,7 +76,7 @@ export class DefaultLinesDiffComputer {
73
76
  const seq2Offset = seq2LastStart + i;
74
77
  if (originalLines[seq1Offset] !== modifiedLines[seq2Offset]) {
75
78
  // This is because of whitespace changes, diff these lines
76
- const characterDiffs = this.refineDiff(originalLines, modifiedLines, new SequenceDiff(new OffsetRange(seq1Offset, seq1Offset + 1), new OffsetRange(seq2Offset, seq2Offset + 1)), timeout, considerWhitespaceChanges, options);
79
+ const characterDiffs = this.refineDiff(originalLines, modifiedLines, new SequenceDiff(new OffsetRange(seq1Offset, seq1Offset + 1), new OffsetRange(seq2Offset, seq2Offset + 1)), timeout, considerWhitespaceChanges, options, rawChanges);
77
80
  for (const a of characterDiffs.mappings) {
78
81
  alignments.push(a);
79
82
  }
@@ -91,7 +94,7 @@ export class DefaultLinesDiffComputer {
91
94
  scanForWhitespaceChanges(equalLinesCount);
92
95
  seq1LastStart = diff.seq1Range.endExclusive;
93
96
  seq2LastStart = diff.seq2Range.endExclusive;
94
- const characterDiffs = this.refineDiff(originalLines, modifiedLines, diff, timeout, considerWhitespaceChanges, options);
97
+ const characterDiffs = this.refineDiff(originalLines, modifiedLines, diff, timeout, considerWhitespaceChanges, options, rawChanges);
95
98
  if (characterDiffs.hitTimeout) {
96
99
  hitTimeout = true;
97
100
  }
@@ -156,14 +159,24 @@ export class DefaultLinesDiffComputer {
156
159
  });
157
160
  return movesWithDiffs;
158
161
  }
159
- refineDiff(originalLines, modifiedLines, diff, timeout, considerWhitespaceChanges, options) {
162
+ refineDiff(originalLines, modifiedLines, diff, timeout, considerWhitespaceChanges, options, rawChanges) {
160
163
  const lineRangeMapping = toLineRangeMapping(diff);
161
164
  const rangeMapping = lineRangeMapping.toRangeMapping2(originalLines, modifiedLines);
162
165
  const slice1 = new LinesSliceCharSequence(originalLines, rangeMapping.originalRange, considerWhitespaceChanges);
163
166
  const slice2 = new LinesSliceCharSequence(modifiedLines, rangeMapping.modifiedRange, considerWhitespaceChanges);
164
- const diffResult = slice1.length + slice2.length < 500
167
+ const useDynamicProgramming = slice1.length + slice2.length < 500;
168
+ const diffResult = useDynamicProgramming
165
169
  ? this.dynamicProgrammingDiffing.compute(slice1, slice2, timeout)
166
170
  : this.myersDiffingAlgorithm.compute(slice1, slice2, timeout);
171
+ let hitTimeout = diffResult.hitTimeout;
172
+ if (rawChanges) {
173
+ // The small-slice display algorithm favors consecutive matches over the longest common subsequence.
174
+ const rawResult = useDynamicProgramming && !hitTimeout ? this.myersDiffingAlgorithm.compute(slice1, slice2, timeout) : diffResult;
175
+ hitTimeout ||= rawResult.hitTimeout;
176
+ for (const change of rawResult.diffs) {
177
+ rawChanges.push(new RangeMapping(slice1.translateRange(change.seq1Range), slice2.translateRange(change.seq2Range)));
178
+ }
179
+ }
167
180
  const check = false;
168
181
  let diffs = diffResult.diffs;
169
182
  if (check) {
@@ -198,7 +211,7 @@ export class DefaultLinesDiffComputer {
198
211
  // Assert: result applied on original should be the same as diff applied to original
199
212
  return {
200
213
  mappings: result,
201
- hitTimeout: diffResult.hitTimeout,
214
+ hitTimeout,
202
215
  };
203
216
  }
204
217
  }