@theia/core 1.72.0-next.2 → 1.72.0-next.21

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.
Files changed (32) hide show
  1. package/README.md +3 -3
  2. package/lib/browser/catalog.json +77 -15
  3. package/lib/browser/frontend-application-module.d.ts +3 -0
  4. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  5. package/lib/browser/frontend-application-module.js +3 -1
  6. package/lib/browser/frontend-application-module.js.map +1 -1
  7. package/lib/browser/keybinding.d.ts +3 -1
  8. package/lib/browser/keybinding.d.ts.map +1 -1
  9. package/lib/browser/keybinding.js +5 -2
  10. package/lib/browser/keybinding.js.map +1 -1
  11. package/lib/browser/keybinding.spec.js +19 -0
  12. package/lib/browser/keybinding.spec.js.map +1 -1
  13. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  14. package/lib/browser/widgets/select-component.js.map +1 -1
  15. package/lib/common/markdown-rendering/markdown-string.d.ts +1 -0
  16. package/lib/common/markdown-rendering/markdown-string.d.ts.map +1 -1
  17. package/lib/common/markdown-rendering/markdown-string.js +24 -2
  18. package/lib/common/markdown-rendering/markdown-string.js.map +1 -1
  19. package/lib/common/markdown-rendering/markdown-string.spec.d.ts +2 -0
  20. package/lib/common/markdown-rendering/markdown-string.spec.d.ts.map +1 -0
  21. package/lib/common/markdown-rendering/markdown-string.spec.js +47 -0
  22. package/lib/common/markdown-rendering/markdown-string.spec.js.map +1 -0
  23. package/package.json +15 -15
  24. package/src/browser/frontend-application-module.ts +3 -1
  25. package/src/browser/keybinding.spec.ts +24 -0
  26. package/src/browser/keybinding.ts +5 -2
  27. package/src/browser/style/index.css +31 -32
  28. package/src/browser/style/scrollbars.css +0 -2
  29. package/src/browser/style/select-component.css +6 -3
  30. package/src/browser/widgets/select-component.tsx +1 -1
  31. package/src/common/markdown-rendering/markdown-string.spec.ts +50 -0
  32. package/src/common/markdown-rendering/markdown-string.ts +24 -2
@@ -0,0 +1,50 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 EclipseSource and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { expect } from 'chai';
18
+ import { MarkdownStringImpl } from './markdown-string';
19
+
20
+ describe('MarkdownStringImpl#appendCodeblock', () => {
21
+
22
+ it('uses a triple-backtick fence for code without backticks', () => {
23
+ const md = new MarkdownStringImpl();
24
+ md.appendCodeblock('json', '{ "type": "adaptive" }');
25
+ expect(md.value).to.equal('\n```json\n{ "type": "adaptive" }\n```\n');
26
+ });
27
+
28
+ it('uses a longer fence when the code contains a triple-backtick run', () => {
29
+ const md = new MarkdownStringImpl();
30
+ const code = 'before\n```json\n{ "x": 1 }\n```\nafter';
31
+ md.appendCodeblock('', code);
32
+ // The fence must be at least 4 backticks so the inner ``` cannot close it.
33
+ expect(md.value).to.equal('\n````\n' + code + '\n````\n');
34
+ });
35
+
36
+ it('grows the fence to be longer than the longest backtick run inside the code', () => {
37
+ const md = new MarkdownStringImpl();
38
+ const code = 'a ```` b ``` c';
39
+ md.appendCodeblock('', code);
40
+ // Longest run is 4, so fence must be 5.
41
+ expect(md.value).to.equal('\n`````\n' + code + '\n`````\n');
42
+ });
43
+
44
+ it('still uses a triple-backtick fence when only single/double backticks appear', () => {
45
+ const md = new MarkdownStringImpl();
46
+ const code = 'inline `code` and ``double`` only';
47
+ md.appendCodeblock('', code);
48
+ expect(md.value).to.equal('\n```\n' + code + '\n```\n');
49
+ });
50
+ });
@@ -90,14 +90,36 @@ export class MarkdownStringImpl implements MarkdownString {
90
90
  }
91
91
 
92
92
  appendCodeblock(langId: string, code: string): MarkdownStringImpl {
93
- this.value += '\n```';
93
+ // Use a fence longer than any run of backticks in the code so that triple-backtick
94
+ // sequences inside `code` cannot prematurely close the surrounding fenced block.
95
+ const fence = '`'.repeat(Math.max(3, MarkdownStringImpl.longestBacktickRun(code) + 1));
96
+ this.value += '\n';
97
+ this.value += fence;
94
98
  this.value += langId;
95
99
  this.value += '\n';
96
100
  this.value += code;
97
- this.value += '\n```\n';
101
+ this.value += '\n';
102
+ this.value += fence;
103
+ this.value += '\n';
98
104
  return this;
99
105
  }
100
106
 
107
+ private static longestBacktickRun(value: string): number {
108
+ let longest = 0;
109
+ let current = 0;
110
+ for (let i = 0; i < value.length; i++) {
111
+ if (value.charCodeAt(i) === 96 /* ` */) {
112
+ current++;
113
+ if (current > longest) {
114
+ longest = current;
115
+ }
116
+ } else {
117
+ current = 0;
118
+ }
119
+ }
120
+ return longest;
121
+ }
122
+
101
123
  appendLink(target: UriComponents | string, label: string, title?: string): MarkdownStringImpl {
102
124
  this.value += '[';
103
125
  this.value += this._escape(label, ']');