@adecore/editor-react 0.31.11 → 0.32.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.
- package/dist/AnchoredPopup.js +73 -19
- package/dist/AttributionCard.js +162 -4
- package/dist/BaselineStatus.js +62 -8
- package/dist/CallHierarchyPanel.js +977 -60
- package/dist/ChangeReview.js +76 -25
- package/dist/CodeAuthorsCard.js +314 -14
- package/dist/CompletionPopup.js +490 -83
- package/dist/DiffView.js +548 -181
- package/dist/EditorContextMenu.js +352 -34
- package/dist/EditorView.js +276 -99
- package/dist/FindReplace.js +525 -67
- package/dist/HoverCard.js +378 -38
- package/dist/HoverSections.js +367 -56
- package/dist/LanguagePopups.js +95 -34
- package/dist/Markdown.js +41 -6
- package/dist/PanelResizeHandle.js +199 -66
- package/dist/PathText.js +49 -7
- package/dist/PeekPanel.js +675 -72
- package/dist/PickPopup.js +304 -34
- package/dist/RenameCard.js +679 -85
- package/dist/RenderedDocs.js +329 -58
- package/dist/SignatureCard.js +91 -7
- package/dist/SplitDiffView.js +344 -254
- package/dist/SymbolPicker.js +440 -85
- package/dist/call-hierarchy-model.js +102 -68
- package/dist/call-hierarchy.js +458 -359
- package/dist/code-actions-model.js +88 -76
- package/dist/code-actions.js +372 -283
- package/dist/code-authors.js +64 -55
- package/dist/code-vision-model.js +134 -127
- package/dist/code-vision.js +224 -206
- package/dist/completion-call.js +94 -67
- package/dist/completion-model.js +334 -244
- package/dist/completion.js +840 -649
- package/dist/conflict-model.js +35 -29
- package/dist/context-menu-rows.js +42 -17
- package/dist/context-menu.js +64 -46
- package/dist/definition-link.js +88 -85
- package/dist/diagnostics-model.js +74 -55
- package/dist/diagnostics.js +121 -100
- package/dist/diff-expansion.js +38 -35
- package/dist/diff-overlays.js +144 -22
- package/dist/diff-syntax.js +65 -42
- package/dist/diff-wordmarks.js +26 -23
- package/dist/doc-comment-model.js +265 -216
- package/dist/editor-language.js +177 -152
- package/dist/error-message.js +2 -2
- package/dist/find-query.js +49 -36
- package/dist/folding.js +81 -62
- package/dist/format-on-type.js +86 -67
- package/dist/highlight-layers.js +19 -20
- package/dist/highlights.js +105 -83
- package/dist/history.js +44 -38
- package/dist/holder.js +18 -18
- package/dist/host-types.js +1 -1
- package/dist/hover-content.js +167 -129
- package/dist/hover.js +285 -245
- package/dist/index.js +10 -10
- package/dist/inlay-hints.js +369 -324
- package/dist/key-priority.js +34 -31
- package/dist/language-ids.js +45 -42
- package/dist/line-edits.js +74 -28
- package/dist/line-text.js +18 -3
- package/dist/locales/en.json +38 -38
- package/dist/locales/nl.json +41 -41
- package/dist/models.js +1 -1
- package/dist/navigation-history.js +40 -41
- package/dist/navigation.js +141 -123
- package/dist/panel-size.js +8 -8
- package/dist/patch-decorations.js +236 -160
- package/dist/patch-layout.js +331 -262
- package/dist/paths.js +3 -3
- package/dist/peek-model.js +86 -69
- package/dist/peek.js +254 -192
- package/dist/pick.js +164 -157
- package/dist/popup-focus.js +5 -5
- package/dist/popup-placement.js +36 -21
- package/dist/popups.js +13 -13
- package/dist/project-language.js +228 -211
- package/dist/project-problems.js +81 -69
- package/dist/proposal-model.js +163 -126
- package/dist/recent-choices.js +25 -25
- package/dist/refresher.js +44 -49
- package/dist/rename-model.js +113 -113
- package/dist/rename.js +321 -233
- package/dist/rendered-docs.d.ts +4 -2
- package/dist/rendered-docs.js +384 -318
- package/dist/rendering-context.js +5 -3
- package/dist/rendering.js +22 -4
- package/dist/review-group.js +42 -39
- package/dist/row-host.d.ts +4 -2
- package/dist/row-host.js +90 -78
- package/dist/selection-ranges.js +21 -17
- package/dist/semantic-delta.js +22 -19
- package/dist/semantic-model.js +86 -73
- package/dist/semantic-tokens.js +201 -162
- package/dist/shortcut-keys.js +16 -10
- package/dist/signature-model.js +34 -28
- package/dist/signature.js +177 -129
- package/dist/snippet-field-transforms.js +118 -106
- package/dist/snippet-indent.js +48 -43
- package/dist/snippet-range-order.js +11 -11
- package/dist/snippet-session.js +703 -667
- package/dist/snippet-transform-client.js +59 -59
- package/dist/snippet-transform-format.js +285 -263
- package/dist/snippet-transform-protocol.js +1 -1
- package/dist/snippet-transform-queue.js +163 -153
- package/dist/snippet-transform-worker.js +42 -35
- package/dist/snippet-variable-names.js +1 -36
- package/dist/snippet-variables.js +53 -63
- package/dist/snippet.js +477 -405
- package/dist/split-alignment.js +47 -35
- package/dist/split-scroll.js +42 -40
- package/dist/symbol-links.js +33 -25
- package/dist/symbol-picker-model.js +126 -116
- package/dist/symbol-picker.js +98 -59
- package/dist/symbols.js +117 -88
- package/dist/testing.js +248 -165
- package/dist/timers.js +35 -30
- package/dist/use-panel-body.js +49 -8
- package/dist/use-problem-counts.js +29 -15
- package/dist/view-state.js +54 -33
- package/dist/word-diff.js +18 -18
- package/dist/workspace-edit.js +300 -249
- package/package.json +6 -6
- package/src/CallHierarchyPanel.tsx +2 -2
- package/src/DiffView.tsx +3 -3
- package/src/FindReplace.tsx +2 -2
- package/src/LanguagePopups.tsx +2 -0
- package/src/PeekPanel.tsx +3 -3
- package/src/RenderedDocs.tsx +9 -10
- package/src/SymbolPicker.tsx +2 -2
- package/src/diff-overlays.tsx +6 -4
- package/src/locales/en.json +38 -38
- package/src/locales/nl.json +41 -41
- package/src/rendered-docs.ts +14 -3
- package/src/row-host.ts +14 -3
package/dist/diagnostics.js
CHANGED
|
@@ -8,109 +8,130 @@ import { comparePositions, markerOf, neighborProblem, problemCountsOf, problemsA
|
|
|
8
8
|
* before the server reports again, so what is under a squiggle is still what it was about.
|
|
9
9
|
*/
|
|
10
10
|
export class DiagnosticsFeature {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
11
|
+
language;
|
|
12
|
+
reports = new Map();
|
|
13
|
+
listeners = new Set();
|
|
14
|
+
list = [];
|
|
15
|
+
constructor(language) {
|
|
16
|
+
this.language = language;
|
|
17
|
+
const {
|
|
18
|
+
editor,
|
|
19
|
+
project,
|
|
20
|
+
uri
|
|
21
|
+
} = language;
|
|
22
|
+
const reports = project.service.onDiagnostics(report => {
|
|
23
|
+
if (report.uri === uri) {
|
|
24
|
+
this.reports.set(report.source, report.diagnostics);
|
|
25
|
+
this.rebuild();
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const edits = editor.onTextChange(change => this.shift(change.changes));
|
|
29
|
+
// These keys are the editor's while it has the keyboard; elsewhere the menu's commands answer.
|
|
30
|
+
const keys = language.onKey(event => {
|
|
31
|
+
const next = isShortcut(this.language.shortcuts.nextProblem, event);
|
|
32
|
+
if (!next && !isShortcut(this.language.shortcuts.previousProblem, event)) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
this.step(next ? 1 : -1);
|
|
36
|
+
return true;
|
|
37
|
+
}, KEY_PRIORITY.diagnostics);
|
|
38
|
+
language.onDispose(() => {
|
|
39
|
+
keys();
|
|
40
|
+
reports.dispose();
|
|
41
|
+
edits();
|
|
42
|
+
this.listeners.clear();
|
|
43
|
+
editor.setMarkers([]);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
get problems() {
|
|
47
|
+
return this.list;
|
|
48
|
+
}
|
|
49
|
+
counts() {
|
|
50
|
+
return problemCountsOf(this.list.map(problem => problem.diagnostic));
|
|
51
|
+
}
|
|
52
|
+
at(position) {
|
|
53
|
+
return problemsAt(this.list, position);
|
|
54
|
+
}
|
|
55
|
+
/* Puts the caret on the next problem, or the one before; false when there is none. */
|
|
56
|
+
step(direction) {
|
|
57
|
+
const caret = this.language.editor.getCaret();
|
|
58
|
+
const target = neighborProblem(this.list, caret, direction);
|
|
59
|
+
if (target === null) {
|
|
60
|
+
return false;
|
|
41
61
|
}
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
const {
|
|
63
|
+
start
|
|
64
|
+
} = target.diagnostic.range;
|
|
65
|
+
this.reveal(target, comparePositions(start, caret) > 0 ? 'centerDown' : 'centerUp');
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
/* Puts the caret on the first problem of the file. */
|
|
69
|
+
goToFirst() {
|
|
70
|
+
const target = neighborProblem(this.list, {
|
|
71
|
+
line: -1,
|
|
72
|
+
character: 0
|
|
73
|
+
}, 1);
|
|
74
|
+
if (target === null) {
|
|
75
|
+
return false;
|
|
44
76
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
this.language.hover.showProblemsAt(editor.getCaret());
|
|
82
|
-
const severity = project.i18n.t(`editor:language.announce.severity.${severityOf(problem.diagnostic)}`);
|
|
83
|
-
editor.announce(project.i18n.t('editor:language.announce.problem', { severity, message: problem.diagnostic.message }));
|
|
84
|
-
}
|
|
85
|
-
/* The problems follow the edit as the markers do. Their number does not change, so nobody is told. */
|
|
86
|
-
shift(changes) {
|
|
87
|
-
let moved = false;
|
|
88
|
-
for (const [server, diagnostics] of this.reports) {
|
|
89
|
-
let shifted = null;
|
|
90
|
-
for (const [index, diagnostic] of diagnostics.entries()) {
|
|
91
|
-
const range = shiftRange(diagnostic.range, changes);
|
|
92
|
-
if (!sameRange(range, diagnostic.range)) {
|
|
93
|
-
shifted ??= [...diagnostics];
|
|
94
|
-
shifted[index] = { ...diagnostic, range };
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
if (shifted !== null) {
|
|
98
|
-
this.reports.set(server, shifted);
|
|
99
|
-
moved = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
if (moved) {
|
|
103
|
-
this.collect();
|
|
77
|
+
this.reveal(target, 'center');
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
onChange(listener) {
|
|
81
|
+
this.listeners.add(listener);
|
|
82
|
+
return () => {
|
|
83
|
+
this.listeners.delete(listener);
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
reveal(problem, reveal) {
|
|
87
|
+
const {
|
|
88
|
+
editor,
|
|
89
|
+
project
|
|
90
|
+
} = this.language;
|
|
91
|
+
editor.setCaret(problem.diagnostic.range.start, reveal);
|
|
92
|
+
editor.focus();
|
|
93
|
+
this.language.hover.showProblemsAt(editor.getCaret());
|
|
94
|
+
const severity = project.i18n.t(`editor:language.announce.severity.${severityOf(problem.diagnostic)}`);
|
|
95
|
+
editor.announce(project.i18n.t('editor:language.announce.problem', {
|
|
96
|
+
severity,
|
|
97
|
+
message: problem.diagnostic.message
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/* The problems follow the edit as the markers do. Their number does not change, so nobody is told. */
|
|
101
|
+
shift(changes) {
|
|
102
|
+
let moved = false;
|
|
103
|
+
for (const [server, diagnostics] of this.reports) {
|
|
104
|
+
let shifted = null;
|
|
105
|
+
for (const [index, diagnostic] of diagnostics.entries()) {
|
|
106
|
+
const range = shiftRange(diagnostic.range, changes);
|
|
107
|
+
if (!sameRange(range, diagnostic.range)) {
|
|
108
|
+
shifted ??= [...diagnostics];
|
|
109
|
+
shifted[index] = {
|
|
110
|
+
...diagnostic,
|
|
111
|
+
range
|
|
112
|
+
};
|
|
104
113
|
}
|
|
114
|
+
}
|
|
115
|
+
if (shifted !== null) {
|
|
116
|
+
this.reports.set(server, shifted);
|
|
117
|
+
moved = true;
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
this.language.editor.setMarkers(this.list.map((problem) => markerOf(problem.diagnostic)));
|
|
109
|
-
for (const listener of [...this.listeners]) {
|
|
110
|
-
listener();
|
|
111
|
-
}
|
|
120
|
+
if (moved) {
|
|
121
|
+
this.collect();
|
|
112
122
|
}
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
}
|
|
124
|
+
rebuild() {
|
|
125
|
+
this.collect();
|
|
126
|
+
this.language.editor.setMarkers(this.list.map(problem => markerOf(problem.diagnostic)));
|
|
127
|
+
for (const listener of [...this.listeners]) {
|
|
128
|
+
listener();
|
|
115
129
|
}
|
|
116
|
-
}
|
|
130
|
+
}
|
|
131
|
+
collect() {
|
|
132
|
+
this.list = [...this.reports].flatMap(([server, diagnostics]) => diagnostics.map(diagnostic => ({
|
|
133
|
+
diagnostic,
|
|
134
|
+
server
|
|
135
|
+
})));
|
|
136
|
+
}
|
|
137
|
+
}
|
package/dist/diff-expansion.js
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { diffRows } from '@adecore/merge';
|
|
2
|
-
export const DEFAULT_UNFOLD_LIMITS = {
|
|
2
|
+
export const DEFAULT_UNFOLD_LIMITS = {
|
|
3
|
+
rows: 20000,
|
|
4
|
+
characters: 2000000,
|
|
5
|
+
lineLength: 10000
|
|
6
|
+
};
|
|
3
7
|
export function fitsDiff(document, unfolded, limits, maxRows = limits.rows) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
const text = row.new === undefined ? document.sides.old[row.old.index] : document.sides.new[row.new.index];
|
|
11
|
-
characters += text.length + (rows > 0 ? 1 : 0);
|
|
12
|
-
if (++rows > maxRows || characters > limits.characters || text.length > limits.lineLength) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
8
|
+
let rows = 0;
|
|
9
|
+
let characters = 0;
|
|
10
|
+
for (const row of diffRows(document, 'unified', unfolded)) {
|
|
11
|
+
if (row.kind === 'gap') {
|
|
12
|
+
continue;
|
|
15
13
|
}
|
|
16
|
-
|
|
14
|
+
const text = row.new === undefined ? document.sides.old[row.old.index] : document.sides.new[row.new.index];
|
|
15
|
+
characters += text.length + (rows > 0 ? 1 : 0);
|
|
16
|
+
if (++rows > maxRows || characters > limits.characters || text.length > limits.lineLength) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
17
21
|
}
|
|
18
22
|
export function expandDiff(document, unfolded, id, limits) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
high = count - 1;
|
|
38
|
-
}
|
|
23
|
+
const rows = diffRows(document, 'unified', unfolded);
|
|
24
|
+
const gap = rows.find(row => row.kind === 'gap' && row.id === id);
|
|
25
|
+
if (gap?.kind !== 'gap' || !gap.unfoldable) {
|
|
26
|
+
return unfolded;
|
|
27
|
+
}
|
|
28
|
+
const visible = rows.filter(row => row.kind === 'line').length;
|
|
29
|
+
const maxRows = Math.min(limits.rows, visible + 500);
|
|
30
|
+
const previous = unfolded.get(id) ?? 0;
|
|
31
|
+
let low = 0;
|
|
32
|
+
let high = Math.min(500, gap.oldCount);
|
|
33
|
+
// Between-hunk gaps reveal from both ends; search the per-end count within the shared row budget.
|
|
34
|
+
while (low < high) {
|
|
35
|
+
const count = Math.ceil((low + high) / 2);
|
|
36
|
+
const candidate = new Map(unfolded).set(id, previous + count);
|
|
37
|
+
if (fitsDiff(document, candidate, limits, maxRows)) {
|
|
38
|
+
low = count;
|
|
39
|
+
} else {
|
|
40
|
+
high = count - 1;
|
|
39
41
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
}
|
|
43
|
+
return low === 0 ? unfolded : new Map(unfolded).set(id, previous + low);
|
|
44
|
+
}
|
package/dist/diff-overlays.js
CHANGED
|
@@ -1,28 +1,150 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useSyncExternalStore } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
5
|
import { Button, Tooltip } from '@adecore/ui';
|
|
6
6
|
import { formatNumber } from '@adecore/ui/format';
|
|
7
7
|
import { RowHost, LineActionHost } from './row-host.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export function DiffOverlays(t0) {
|
|
10
|
+
const $ = _c(29);
|
|
11
|
+
const {
|
|
12
|
+
mounted,
|
|
13
|
+
display,
|
|
14
|
+
unfold,
|
|
15
|
+
blocked
|
|
16
|
+
} = t0;
|
|
17
|
+
const {
|
|
18
|
+
t
|
|
19
|
+
} = useTranslation("editor");
|
|
20
|
+
let t1;
|
|
21
|
+
if ($[0] !== mounted.rows) {
|
|
22
|
+
t1 = () => mounted.rows.getContainers();
|
|
23
|
+
$[0] = mounted.rows;
|
|
24
|
+
$[1] = t1;
|
|
25
|
+
} else {
|
|
26
|
+
t1 = $[1];
|
|
27
|
+
}
|
|
28
|
+
const getRows = t1;
|
|
29
|
+
let t2;
|
|
30
|
+
if ($[2] !== mounted.actions) {
|
|
31
|
+
t2 = () => mounted.actions.getContainers();
|
|
32
|
+
$[2] = mounted.actions;
|
|
33
|
+
$[3] = t2;
|
|
34
|
+
} else {
|
|
35
|
+
t2 = $[3];
|
|
36
|
+
}
|
|
37
|
+
const getActions = t2;
|
|
38
|
+
let t3;
|
|
39
|
+
if ($[4] !== mounted.rows) {
|
|
40
|
+
t3 = listener => mounted.rows.subscribe(listener);
|
|
41
|
+
$[4] = mounted.rows;
|
|
42
|
+
$[5] = t3;
|
|
43
|
+
} else {
|
|
44
|
+
t3 = $[5];
|
|
45
|
+
}
|
|
46
|
+
const rows = useSyncExternalStore(t3, getRows, getRows);
|
|
47
|
+
let t4;
|
|
48
|
+
if ($[6] !== mounted.actions) {
|
|
49
|
+
t4 = listener_0 => mounted.actions.subscribe(listener_0);
|
|
50
|
+
$[6] = mounted.actions;
|
|
51
|
+
$[7] = t4;
|
|
52
|
+
} else {
|
|
53
|
+
t4 = $[7];
|
|
54
|
+
}
|
|
55
|
+
const actions = useSyncExternalStore(t4, getActions, getActions);
|
|
56
|
+
let t5;
|
|
57
|
+
if ($[8] !== blocked || $[9] !== display.gaps || $[10] !== rows || $[11] !== t || $[12] !== unfold) {
|
|
58
|
+
let t6;
|
|
59
|
+
if ($[14] !== blocked || $[15] !== rows || $[16] !== t || $[17] !== unfold) {
|
|
60
|
+
t6 = t7 => {
|
|
61
|
+
const {
|
|
62
|
+
row
|
|
63
|
+
} = t7;
|
|
64
|
+
const container = rows.get(`gap-${row.id}`);
|
|
65
|
+
if (container === undefined) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
const text = t("diff.hidden", {
|
|
69
|
+
count: formatNumber(Math.max(row.oldCount, row.newCount))
|
|
70
|
+
});
|
|
71
|
+
return createPortal(/*#__PURE__*/_jsx("div", {
|
|
72
|
+
className: "adecore-editor-diff-gap",
|
|
73
|
+
children: row.unfoldable && blocked?.has(row.id) === true ? /*#__PURE__*/_jsx(Tooltip, {
|
|
74
|
+
label: t("diff.contextLimit"),
|
|
75
|
+
children: /*#__PURE__*/_jsx("span", {
|
|
76
|
+
className: "inline-flex",
|
|
77
|
+
children: /*#__PURE__*/_jsx(Button, {
|
|
78
|
+
size: "xs",
|
|
79
|
+
disabled: true,
|
|
80
|
+
children: text
|
|
81
|
+
})
|
|
82
|
+
})
|
|
83
|
+
}) : row.unfoldable ? /*#__PURE__*/_jsx(Button, {
|
|
84
|
+
size: "xs",
|
|
85
|
+
onClick: () => unfold(row.id),
|
|
86
|
+
children: text
|
|
87
|
+
}) : /*#__PURE__*/_jsx("span", {
|
|
88
|
+
children: text
|
|
89
|
+
})
|
|
90
|
+
}), container, `gap-${row.id}`);
|
|
91
|
+
};
|
|
92
|
+
$[14] = blocked;
|
|
93
|
+
$[15] = rows;
|
|
94
|
+
$[16] = t;
|
|
95
|
+
$[17] = unfold;
|
|
96
|
+
$[18] = t6;
|
|
97
|
+
} else {
|
|
98
|
+
t6 = $[18];
|
|
99
|
+
}
|
|
100
|
+
t5 = display.gaps.map(t6);
|
|
101
|
+
$[8] = blocked;
|
|
102
|
+
$[9] = display.gaps;
|
|
103
|
+
$[10] = rows;
|
|
104
|
+
$[11] = t;
|
|
105
|
+
$[12] = unfold;
|
|
106
|
+
$[13] = t5;
|
|
107
|
+
} else {
|
|
108
|
+
t5 = $[13];
|
|
109
|
+
}
|
|
110
|
+
let t6;
|
|
111
|
+
if ($[19] !== actions || $[20] !== display.rows || $[21] !== t) {
|
|
112
|
+
let t7;
|
|
113
|
+
if ($[23] !== actions || $[24] !== t) {
|
|
114
|
+
t7 = (row_0, index) => {
|
|
115
|
+
if (row_0.noNewline === undefined) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const container_0 = actions.get(`no-newline-${index}`);
|
|
119
|
+
return container_0 === undefined ? null : createPortal(/*#__PURE__*/_jsx("span", {
|
|
120
|
+
className: "adecore-editor-diff-no-newline",
|
|
121
|
+
children: t("diff.noNewline")
|
|
122
|
+
}), container_0, `no-newline-${index}`);
|
|
123
|
+
};
|
|
124
|
+
$[23] = actions;
|
|
125
|
+
$[24] = t;
|
|
126
|
+
$[25] = t7;
|
|
127
|
+
} else {
|
|
128
|
+
t7 = $[25];
|
|
129
|
+
}
|
|
130
|
+
t6 = display.rows.map(t7);
|
|
131
|
+
$[19] = actions;
|
|
132
|
+
$[20] = display.rows;
|
|
133
|
+
$[21] = t;
|
|
134
|
+
$[22] = t6;
|
|
135
|
+
} else {
|
|
136
|
+
t6 = $[22];
|
|
137
|
+
}
|
|
138
|
+
let t7;
|
|
139
|
+
if ($[26] !== t5 || $[27] !== t6) {
|
|
140
|
+
t7 = /*#__PURE__*/_jsxs(_Fragment, {
|
|
141
|
+
children: [t5, t6]
|
|
142
|
+
});
|
|
143
|
+
$[26] = t5;
|
|
144
|
+
$[27] = t6;
|
|
145
|
+
$[28] = t7;
|
|
146
|
+
} else {
|
|
147
|
+
t7 = $[28];
|
|
148
|
+
}
|
|
149
|
+
return t7;
|
|
150
|
+
}
|
package/dist/diff-syntax.js
CHANGED
|
@@ -1,49 +1,72 @@
|
|
|
1
1
|
function canTokenize(source) {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
if (source.length > 20000) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
let characters = Math.max(0, source.length - 1);
|
|
6
|
+
for (const line of source) {
|
|
7
|
+
characters += line.length;
|
|
8
|
+
if (line.length > 10000 || characters > 2000000) {
|
|
9
|
+
return false;
|
|
4
10
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
characters += line.length;
|
|
8
|
-
if (line.length > 10000 || characters > 2000000) {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return true;
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
13
13
|
}
|
|
14
14
|
export function diffSyntaxDocument(document, language, theme) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
15
|
+
const locations = {
|
|
16
|
+
old: [],
|
|
17
|
+
new: []
|
|
18
|
+
};
|
|
19
|
+
const build = side => {
|
|
20
|
+
const source = document.sides[side];
|
|
21
|
+
// Skipping a long hidden line loses grammar state; keep the entire side plain instead.
|
|
22
|
+
if (!canTokenize(source)) {
|
|
23
|
+
return {
|
|
24
|
+
language,
|
|
25
|
+
theme,
|
|
26
|
+
blocks: [],
|
|
27
|
+
resets: []
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const blocks = [];
|
|
31
|
+
const resets = [];
|
|
32
|
+
const ranges = document.snapshots ? [{
|
|
33
|
+
from: 0,
|
|
34
|
+
to: source.length
|
|
35
|
+
}] : document.offsets.map((offset, index) => ({
|
|
36
|
+
from: offset[side],
|
|
37
|
+
to: document.offsets[index + 1]?.[side] ?? source.length
|
|
38
|
+
}));
|
|
39
|
+
for (const range of ranges) {
|
|
40
|
+
if (!document.snapshots && range.from < range.to) {
|
|
41
|
+
resets.push(blocks.length);
|
|
42
|
+
}
|
|
43
|
+
for (let from = range.from; from < range.to; from += 200) {
|
|
44
|
+
const to = Math.min(from + 200, range.to);
|
|
45
|
+
const block = blocks.length;
|
|
46
|
+
blocks.push(source.slice(from, to).join('\n'));
|
|
47
|
+
for (let index = from; index < to; index++) {
|
|
48
|
+
locations[side][index] = {
|
|
49
|
+
block,
|
|
50
|
+
line: index - from
|
|
51
|
+
};
|
|
39
52
|
}
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
const documents = { old: build('old'), new: build('new') };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
43
55
|
return {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
language,
|
|
57
|
+
theme,
|
|
58
|
+
blocks,
|
|
59
|
+
resets
|
|
48
60
|
};
|
|
49
|
-
}
|
|
61
|
+
};
|
|
62
|
+
const documents = {
|
|
63
|
+
old: build('old'),
|
|
64
|
+
new: build('new')
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
documents,
|
|
68
|
+
locate(side, index) {
|
|
69
|
+
return Number.isInteger(index) && index >= 0 ? locations[side][index] : undefined;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
package/dist/diff-wordmarks.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { diffRows, wordChanges } from '@adecore/merge';
|
|
2
2
|
export function wordMarks(document) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
characters += old.length + fresh.length;
|
|
13
|
-
// Per-pair limits alone still allow thousands of expensive word diffs during one mount.
|
|
14
|
-
if (++pairs > 1000 || characters > 100000) {
|
|
15
|
-
break;
|
|
16
|
-
}
|
|
17
|
-
const words = wordChanges(old, fresh);
|
|
18
|
-
if (words === null) {
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
const ranges = (text, ranges) => ranges.filter((range) => !document.ignoreWhitespace || /\S/.test(text.slice(range.from, range.to))).map((range) => [range.from, range.to]);
|
|
22
|
-
marks.old.set(row.old.index, ranges(old, words.old));
|
|
23
|
-
marks.new.set(row.new.index, ranges(fresh, words.new));
|
|
3
|
+
const marks = {
|
|
4
|
+
old: new Map(),
|
|
5
|
+
new: new Map()
|
|
6
|
+
};
|
|
7
|
+
let pairs = 0;
|
|
8
|
+
let characters = 0;
|
|
9
|
+
for (const row of diffRows(document, 'split')) {
|
|
10
|
+
if (row.kind !== 'line' || row.change !== 'pair' || document.hunks[row.hunk].coarse) {
|
|
11
|
+
continue;
|
|
24
12
|
}
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
const old = document.sides.old[row.old.index];
|
|
14
|
+
const fresh = document.sides.new[row.new.index];
|
|
15
|
+
characters += old.length + fresh.length;
|
|
16
|
+
// Per-pair limits alone still allow thousands of expensive word diffs during one mount.
|
|
17
|
+
if (++pairs > 1000 || characters > 100000) {
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
const words = wordChanges(old, fresh);
|
|
21
|
+
if (words === null) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const ranges = (text, ranges) => ranges.filter(range => !document.ignoreWhitespace || /\S/.test(text.slice(range.from, range.to))).map(range => [range.from, range.to]);
|
|
25
|
+
marks.old.set(row.old.index, ranges(old, words.old));
|
|
26
|
+
marks.new.set(row.new.index, ranges(fresh, words.new));
|
|
27
|
+
}
|
|
28
|
+
return marks;
|
|
29
|
+
}
|