@codingame/monaco-vscode-xterm-addons-common 34.1.3 → 35.0.0

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.
@@ -355,13 +355,10 @@ let XtermTerminal = class XtermTerminal extends Disposable {
355
355
  getContentsAsText(startMarker, endMarker) {
356
356
  const lines = [];
357
357
  const buffer = this.raw.buffer.active;
358
- if (startMarker?.line === -1) {
359
- throw ( new Error("Cannot get contents of a disposed startMarker"));
360
- }
361
358
  if (endMarker?.line === -1) {
362
359
  throw ( new Error("Cannot get contents of a disposed endMarker"));
363
360
  }
364
- const startLine = startMarker?.line ?? 0;
361
+ const startLine = (startMarker === undefined || startMarker.line === -1) ? 0 : startMarker.line;
365
362
  const endLine = endMarker?.line ?? buffer.length - 1;
366
363
  for (let y = startLine; y <= endLine; y++) {
367
364
  lines.push(buffer.getLine(y)?.translateToString(true) ?? "");
@@ -755,7 +752,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
755
752
  await this._clipboardService.writeText(this.raw.getSelection());
756
753
  }
757
754
  } else {
758
- this._notificationService.warn(( localize(14314, "The terminal has no selection to copy")));
755
+ this._notificationService.warn(( localize(14958, "The terminal has no selection to copy")));
759
756
  }
760
757
  }
761
758
  _setCursorBlink(blink) {
@@ -821,18 +818,21 @@ let XtermTerminal = class XtermTerminal extends Disposable {
821
818
  const ligaturesConfig = this._terminalConfigurationService.config.fontLigatures;
822
819
  let shouldRecreateWebglRenderer = false;
823
820
  if (ligaturesConfig?.enabled) {
824
- if (this._ligaturesAddon.value && !equals(ligaturesConfig, this._ligaturesAddonConfig)) {
821
+ const ligatureOptions = {
822
+ fontFeatureSettings: ligaturesConfig.featureSettings,
823
+ fallbackLigatures: ligaturesConfig.fallbackLigatures
824
+ };
825
+ if (this._ligaturesAddon.value && !equals(ligatureOptions, this._ligaturesAddonConfig)) {
825
826
  this._ligaturesAddon.clear();
827
+ this._ligaturesAddonConfig = undefined;
826
828
  }
827
829
  if (!this._ligaturesAddon.value) {
828
830
  const LigaturesAddon = await this._xtermAddonLoader.importAddon("ligatures");
829
831
  if (this._store.isDisposed) {
830
832
  return;
831
833
  }
832
- this._ligaturesAddon.value = this._instantiationService.createInstance(LigaturesAddon, {
833
- fontFeatureSettings: ligaturesConfig.featureSettings,
834
- fallbackLigatures: ligaturesConfig.fallbackLigatures
835
- });
834
+ this._ligaturesAddon.value = this._instantiationService.createInstance(LigaturesAddon, ligatureOptions);
835
+ this._ligaturesAddonConfig = ligatureOptions;
836
836
  this.raw.loadAddon(this._ligaturesAddon.value);
837
837
  shouldRecreateWebglRenderer = true;
838
838
  }
@@ -841,6 +841,7 @@ let XtermTerminal = class XtermTerminal extends Disposable {
841
841
  return;
842
842
  }
843
843
  this._ligaturesAddon.clear();
844
+ this._ligaturesAddonConfig = undefined;
844
845
  shouldRecreateWebglRenderer = true;
845
846
  }
846
847
  if (shouldRecreateWebglRenderer && this._webglAddon) {
@@ -1,151 +0,0 @@
1
-
2
-
3
- const maxInputLength = 200_000;
4
- function convertHtmlToMarkdown(html) {
5
- if (html.length > maxInputLength) {
6
- return html.replace(/<[^>]+>/g, "");
7
- }
8
- let md = html;
9
- md = md.replace(/\r\n?/g, "\n");
10
- md = md.replace(
11
- /<h1[^>]*>([\s\S]*?)<\/h1>/gi,
12
- (_m, inner) => `\n# ${inlineClean(inner)}\n`
13
- );
14
- md = md.replace(
15
- /<h2[^>]*>([\s\S]*?)<\/h2>/gi,
16
- (_m, inner) => `\n## ${inlineClean(inner)}\n`
17
- );
18
- md = md.replace(
19
- /<h3[^>]*>([\s\S]*?)<\/h3>/gi,
20
- (_m, inner) => `\n### ${inlineClean(inner)}\n`
21
- );
22
- md = md.replace(
23
- /<h4[^>]*>([\s\S]*?)<\/h4>/gi,
24
- (_m, inner) => `\n#### ${inlineClean(inner)}\n`
25
- );
26
- md = md.replace(
27
- /<h5[^>]*>([\s\S]*?)<\/h5>/gi,
28
- (_m, inner) => `\n##### ${inlineClean(inner)}\n`
29
- );
30
- md = md.replace(
31
- /<h6[^>]*>([\s\S]*?)<\/h6>/gi,
32
- (_m, inner) => `\n###### ${inlineClean(inner)}\n`
33
- );
34
- md = md.replace(
35
- /<pre[^>]*>\s*<code[^>]*>([\s\S]*?)<\/code>\s*<\/pre>/gi,
36
- (_m, inner) => `\n\`\`\`\n${cleanCodeBlock(inner)}\n\`\`\`\n`
37
- );
38
- md = md.replace(
39
- /<pre[^>]*>([\s\S]*?)<\/pre>/gi,
40
- (_m, inner) => `\n\`\`\`\n${cleanCodeBlock(inner)}\n\`\`\`\n`
41
- );
42
- md = md.replace(/<blockquote[^>]*>([\s\S]*?)<\/blockquote>/gi, (_m, inner) => {
43
- const lines = ( inlineClean(inner).split("\n").map(l => `> ${l.trim()}`));
44
- return `\n${lines.join("\n")}\n`;
45
- });
46
- md = md.replace(/<ol[^>]*>([\s\S]*?)<\/ol>/gi, (_m, inner) => {
47
- let index = 0;
48
- const numbered = inner.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, (_liM, liInner) => {
49
- index++;
50
- return `${index}. ${inlineClean(liInner).trim()}\n`;
51
- });
52
- return `\n${numbered.replace(/<[^>]+>/g, "")}\n`;
53
- });
54
- md = md.replace(
55
- /<li[^>]*>([\s\S]*?)<\/li>/gi,
56
- (_m, inner) => `- ${inlineClean(inner).trim()}\n`
57
- );
58
- md = md.replace(/<\/?ul[^>]*>/gi, "\n");
59
- md = md.replace(/<\/p>/gi, "\n\n");
60
- md = md.replace(/<p[^>]*>/gi, "");
61
- md = md.replace(/<\/div>/gi, "\n");
62
- md = md.replace(/<div[^>]*>/gi, "");
63
- md = md.replace(/<br\s*\/?>/gi, "\n");
64
- md = md.replace(/<hr[^>]*\/?>/gi, "\n---\n");
65
- md = md.replace(
66
- /<a\s[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,
67
- (_m, href, text) => sanitizeLink(href, inlineClean(text).trim())
68
- );
69
- md = md.replace(/<img\s[^>]*alt="([^"]*)"[^>]*src="([^"]*)"[^>]*\/?>/gi, "![$1]($2)");
70
- md = md.replace(/<img\s[^>]*src="([^"]*)"[^>]*alt="([^"]*)"[^>]*\/?>/gi, "![$2]($1)");
71
- md = md.replace(/<img\s[^>]*src="([^"]*)"[^>]*\/?>/gi, "![]($1)");
72
- md = md.replace(
73
- /<(strong|b)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
74
- (_m, _tag, _attrs, inner) => `**${inlineClean(inner)}**`
75
- );
76
- md = md.replace(
77
- /<(em|i)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
78
- (_m, _tag, _attrs, inner) => `*${inlineClean(inner)}*`
79
- );
80
- md = md.replace(
81
- /<code(\s[^>]*)?>([\s\S]*?)<\/code>/gi,
82
- (_m, _attrs, inner) => `\`${decodeEntities(inner)}\``
83
- );
84
- md = md.replace(
85
- /<(del|s|strike)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
86
- (_m, _tag, _attrs, inner) => `~~${inlineClean(inner)}~~`
87
- );
88
- md = md.replace(/<[^>]+>/g, "");
89
- md = decodeEntities(md);
90
- md = md.replace(/\n{3,}/g, "\n\n");
91
- return md.trim();
92
- }
93
- function inlineClean(html) {
94
- let result = html;
95
- result = result.replace(
96
- /<a\s[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,
97
- (_m, href, text) => sanitizeLink(href, inlineClean(text).trim())
98
- );
99
- result = result.replace(
100
- /<(strong|b)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
101
- (_m, _tag, _attrs, inner) => `**${inlineClean(inner)}**`
102
- );
103
- result = result.replace(
104
- /<(em|i)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
105
- (_m, _tag, _attrs, inner) => `*${inlineClean(inner)}*`
106
- );
107
- result = result.replace(
108
- /<code(\s[^>]*)?>([\s\S]*?)<\/code>/gi,
109
- (_m, _attrs, inner) => `\`${decodeEntities(inner)}\``
110
- );
111
- result = result.replace(
112
- /<(del|s|strike)(\s[^>]*)?>([\s\S]*?)<\/\1>/gi,
113
- (_m, _tag, _attrs, inner) => `~~${inlineClean(inner)}~~`
114
- );
115
- result = result.replace(/<br\s*\/?>/gi, "\n");
116
- result = result.replace(/<[^>]+>/g, "");
117
- return decodeEntities(result);
118
- }
119
- function cleanCodeBlock(html) {
120
- let result = html;
121
- result = result.replace(/<br\s*\/?>/gi, "\n");
122
- result = result.replace(/<[^>]+>/g, "");
123
- result = decodeEntities(result);
124
- result = result.replace(/^\n+|\n+$/g, "");
125
- return result;
126
- }
127
- function sanitizeLink(href, text) {
128
- if (/^(javascript|vbscript|data):/i.test(href.trim())) {
129
- return text;
130
- }
131
- return `[${text}](${href})`;
132
- }
133
- function decodeEntities(text) {
134
- return text.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, "\"").replace(/&#39;/g, "'").replace(/&nbsp;/g, " ").replace(
135
- /&#x(?<hex>[0-9a-fA-F]+);/g,
136
- (...args) => safeFromCodePoint(parseInt(args.at(-1).hex, 16))
137
- ).replace(
138
- /&#(?<dec>\d+);/g,
139
- (...args) => safeFromCodePoint(parseInt(args.at(-1).dec, 10))
140
- );
141
- }
142
- function safeFromCodePoint(code) {
143
- if (code >= 0 && code <= 0x10FFFF) {
144
- try {
145
- return String.fromCodePoint(code);
146
- } catch {}
147
- }
148
- return "";
149
- }
150
-
151
- export { convertHtmlToMarkdown };