ide-assi 0.347.0 → 0.349.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/bundle.cjs.js +44 -47
- package/dist/bundle.esm.js +44 -47
- package/dist/components/ideDiff.js +11 -14
- package/package.json +1 -1
- package/src/components/ideDiff.js +11 -14
package/dist/bundle.cjs.js
CHANGED
|
@@ -202480,7 +202480,7 @@ function codePointSize$1(code) { return code < 0x10000 ? 1 : 2 }
|
|
|
202480
202480
|
/**
|
|
202481
202481
|
The data structure for documents. @nonabstract
|
|
202482
202482
|
*/
|
|
202483
|
-
class Text {
|
|
202483
|
+
let Text$1 = class Text {
|
|
202484
202484
|
/**
|
|
202485
202485
|
Get the line description around the given position.
|
|
202486
202486
|
*/
|
|
@@ -202604,11 +202604,11 @@ class Text {
|
|
|
202604
202604
|
return Text.empty;
|
|
202605
202605
|
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
202606
202606
|
}
|
|
202607
|
-
}
|
|
202607
|
+
};
|
|
202608
202608
|
// Leaves store an array of line strings. There are always line breaks
|
|
202609
202609
|
// between these strings. Leaves are limited in size and have to be
|
|
202610
202610
|
// contained in TextNode instances for bigger documents.
|
|
202611
|
-
class TextLeaf extends Text {
|
|
202611
|
+
class TextLeaf extends Text$1 {
|
|
202612
202612
|
constructor(text, length = textLength(text)) {
|
|
202613
202613
|
super();
|
|
202614
202614
|
this.text = text;
|
|
@@ -202691,7 +202691,7 @@ class TextLeaf extends Text {
|
|
|
202691
202691
|
// number of other nodes or leaves, taking care to balance themselves
|
|
202692
202692
|
// on changes. There are implied line breaks _between_ the children of
|
|
202693
202693
|
// a node (but not before the first or after the last child).
|
|
202694
|
-
class TextNode extends Text {
|
|
202694
|
+
class TextNode extends Text$1 {
|
|
202695
202695
|
constructor(children, length) {
|
|
202696
202696
|
super();
|
|
202697
202697
|
this.children = children;
|
|
@@ -202827,7 +202827,7 @@ class TextNode extends Text {
|
|
|
202827
202827
|
return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
|
|
202828
202828
|
}
|
|
202829
202829
|
}
|
|
202830
|
-
Text.empty = /*@__PURE__*/new TextLeaf([""], 0);
|
|
202830
|
+
Text$1.empty = /*@__PURE__*/new TextLeaf([""], 0);
|
|
202831
202831
|
function textLength(text) {
|
|
202832
202832
|
let length = -1;
|
|
202833
202833
|
for (let line of text)
|
|
@@ -202994,7 +202994,7 @@ class LineCursor {
|
|
|
202994
202994
|
get lineBreak() { return false; }
|
|
202995
202995
|
}
|
|
202996
202996
|
if (typeof Symbol != "undefined") {
|
|
202997
|
-
Text.prototype[Symbol.iterator] = function () { return this.iter(); };
|
|
202997
|
+
Text$1.prototype[Symbol.iterator] = function () { return this.iter(); };
|
|
202998
202998
|
RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =
|
|
202999
202999
|
LineCursor.prototype[Symbol.iterator] = function () { return this; };
|
|
203000
203000
|
}
|
|
@@ -203318,8 +203318,8 @@ class ChangeSet extends ChangeDesc {
|
|
|
203318
203318
|
sections[i + 1] = len;
|
|
203319
203319
|
let index = i >> 1;
|
|
203320
203320
|
while (inserted.length < index)
|
|
203321
|
-
inserted.push(Text.empty);
|
|
203322
|
-
inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
|
|
203321
|
+
inserted.push(Text$1.empty);
|
|
203322
|
+
inserted.push(len ? doc.slice(pos, pos + len) : Text$1.empty);
|
|
203323
203323
|
}
|
|
203324
203324
|
pos += len;
|
|
203325
203325
|
}
|
|
@@ -203446,7 +203446,7 @@ class ChangeSet extends ChangeDesc {
|
|
|
203446
203446
|
let { from, to = from, insert } = spec;
|
|
203447
203447
|
if (from > to || from < 0 || to > length)
|
|
203448
203448
|
throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
|
|
203449
|
-
let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
|
|
203449
|
+
let insText = !insert ? Text$1.empty : typeof insert == "string" ? Text$1.of(insert.split(lineSep || DefaultSplit)) : insert;
|
|
203450
203450
|
let insLen = insText.length;
|
|
203451
203451
|
if (from == to && insLen == 0)
|
|
203452
203452
|
return;
|
|
@@ -203490,8 +203490,8 @@ class ChangeSet extends ChangeDesc {
|
|
|
203490
203490
|
}
|
|
203491
203491
|
else {
|
|
203492
203492
|
while (inserted.length < i)
|
|
203493
|
-
inserted.push(Text.empty);
|
|
203494
|
-
inserted[i] = Text.of(part.slice(1));
|
|
203493
|
+
inserted.push(Text$1.empty);
|
|
203494
|
+
inserted[i] = Text$1.of(part.slice(1));
|
|
203495
203495
|
sections.push(part[0], inserted[i].length);
|
|
203496
203496
|
}
|
|
203497
203497
|
}
|
|
@@ -203528,7 +203528,7 @@ function addInsert(values, sections, value) {
|
|
|
203528
203528
|
}
|
|
203529
203529
|
else {
|
|
203530
203530
|
while (values.length < index)
|
|
203531
|
-
values.push(Text.empty);
|
|
203531
|
+
values.push(Text$1.empty);
|
|
203532
203532
|
values.push(value);
|
|
203533
203533
|
}
|
|
203534
203534
|
}
|
|
@@ -203541,7 +203541,7 @@ function iterChanges(desc, f, individual) {
|
|
|
203541
203541
|
posB += len;
|
|
203542
203542
|
}
|
|
203543
203543
|
else {
|
|
203544
|
-
let endA = posA, endB = posB, text = Text.empty;
|
|
203544
|
+
let endA = posA, endB = posB, text = Text$1.empty;
|
|
203545
203545
|
for (;;) {
|
|
203546
203546
|
endA += len;
|
|
203547
203547
|
endB += ins;
|
|
@@ -203697,11 +203697,11 @@ class SectionIter {
|
|
|
203697
203697
|
get len2() { return this.ins < 0 ? this.len : this.ins; }
|
|
203698
203698
|
get text() {
|
|
203699
203699
|
let { inserted } = this.set, index = (this.i - 2) >> 1;
|
|
203700
|
-
return index >= inserted.length ? Text.empty : inserted[index];
|
|
203700
|
+
return index >= inserted.length ? Text$1.empty : inserted[index];
|
|
203701
203701
|
}
|
|
203702
203702
|
textBit(len) {
|
|
203703
203703
|
let { inserted } = this.set, index = (this.i - 2) >> 1;
|
|
203704
|
-
return index >= inserted.length && !len ? Text.empty
|
|
203704
|
+
return index >= inserted.length && !len ? Text$1.empty
|
|
203705
203705
|
: inserted[index].slice(this.off, len == null ? undefined : this.off + len);
|
|
203706
203706
|
}
|
|
203707
203707
|
forward(len) {
|
|
@@ -205145,7 +205145,7 @@ class EditorState {
|
|
|
205145
205145
|
[`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
|
|
205146
205146
|
*/
|
|
205147
205147
|
toText(string) {
|
|
205148
|
-
return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
|
|
205148
|
+
return Text$1.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
|
|
205149
205149
|
}
|
|
205150
205150
|
/**
|
|
205151
205151
|
Return the given range of the document as a string.
|
|
@@ -205212,8 +205212,8 @@ class EditorState {
|
|
|
205212
205212
|
*/
|
|
205213
205213
|
static create(config = {}) {
|
|
205214
205214
|
let configuration = Configuration.resolve(config.extensions || [], new Map);
|
|
205215
|
-
let doc = config.doc instanceof Text ? config.doc
|
|
205216
|
-
: Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
|
|
205215
|
+
let doc = config.doc instanceof Text$1 ? config.doc
|
|
205216
|
+
: Text$1.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
|
|
205217
205217
|
let selection = !config.selection ? EditorSelection.single(0)
|
|
205218
205218
|
: config.selection instanceof EditorSelection ? config.selection
|
|
205219
205219
|
: EditorSelection.single(config.selection.anchor, config.selection.head);
|
|
@@ -207625,12 +207625,12 @@ class WidgetView extends ContentView {
|
|
|
207625
207625
|
ignoreEvent(event) { return this.widget.ignoreEvent(event); }
|
|
207626
207626
|
get overrideDOMText() {
|
|
207627
207627
|
if (this.length == 0)
|
|
207628
|
-
return Text.empty;
|
|
207628
|
+
return Text$1.empty;
|
|
207629
207629
|
let top = this;
|
|
207630
207630
|
while (top.parent)
|
|
207631
207631
|
top = top.parent;
|
|
207632
207632
|
let { view } = top, text = view && view.state.doc, start = this.posAtStart;
|
|
207633
|
-
return text ? text.slice(start, start + this.length) : Text.empty;
|
|
207633
|
+
return text ? text.slice(start, start + this.length) : Text$1.empty;
|
|
207634
207634
|
}
|
|
207635
207635
|
domAtPos(pos) {
|
|
207636
207636
|
return (this.length ? pos == 0 : this.side > 0)
|
|
@@ -207692,7 +207692,7 @@ class WidgetBufferView extends ContentView {
|
|
|
207692
207692
|
return this.dom.getBoundingClientRect();
|
|
207693
207693
|
}
|
|
207694
207694
|
get overrideDOMText() {
|
|
207695
|
-
return Text.empty;
|
|
207695
|
+
return Text$1.empty;
|
|
207696
207696
|
}
|
|
207697
207697
|
get isHidden() { return true; }
|
|
207698
207698
|
}
|
|
@@ -208316,7 +208316,7 @@ class BlockWidgetView extends ContentView {
|
|
|
208316
208316
|
}
|
|
208317
208317
|
}
|
|
208318
208318
|
get overrideDOMText() {
|
|
208319
|
-
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
|
|
208319
|
+
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$1.empty;
|
|
208320
208320
|
}
|
|
208321
208321
|
domBoundsAround() { return null; }
|
|
208322
208322
|
become(other) {
|
|
@@ -210656,7 +210656,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210656
210656
|
diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)
|
|
210657
210657
|
diff.toB--;
|
|
210658
210658
|
change = { from: from + diff.from, to: from + diff.toA,
|
|
210659
|
-
insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
210659
|
+
insert: Text$1.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
210660
210660
|
}
|
|
210661
210661
|
}
|
|
210662
210662
|
else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
|
|
@@ -210674,7 +210674,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210674
210674
|
// and transform it into a regular space insert.
|
|
210675
210675
|
if (newSel && change.insert.length == 2)
|
|
210676
210676
|
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
210677
|
-
change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
|
|
210677
|
+
change = { from: change.from, to: change.to, insert: Text$1.of([change.insert.toString().replace(".", " ")]) };
|
|
210678
210678
|
}
|
|
210679
210679
|
else if (change && change.from >= sel.from && change.to <= sel.to &&
|
|
210680
210680
|
(change.from != sel.from || change.to != sel.to) &&
|
|
@@ -210694,7 +210694,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210694
210694
|
// bogus new line to be created in CodeMirror (#968)
|
|
210695
210695
|
if (newSel)
|
|
210696
210696
|
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
210697
|
-
change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
|
|
210697
|
+
change = { from: sel.from, to: sel.to, insert: Text$1.of([" "]) };
|
|
210698
210698
|
}
|
|
210699
210699
|
if (change) {
|
|
210700
210700
|
return applyDOMChangeInner(view, change, newSel, lastKey);
|
|
@@ -211747,7 +211747,7 @@ function clearHeightChangeFlag() { heightChangeFlag = false; }
|
|
|
211747
211747
|
class HeightOracle {
|
|
211748
211748
|
constructor(lineWrapping) {
|
|
211749
211749
|
this.lineWrapping = lineWrapping;
|
|
211750
|
-
this.doc = Text.empty;
|
|
211750
|
+
this.doc = Text$1.empty;
|
|
211751
211751
|
this.heightSamples = {};
|
|
211752
211752
|
this.lineHeight = 14; // The height of an entire line (line-height)
|
|
211753
211753
|
this.charWidth = 7;
|
|
@@ -212594,7 +212594,7 @@ class ViewState {
|
|
|
212594
212594
|
let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping");
|
|
212595
212595
|
this.heightOracle = new HeightOracle(guessWrapping);
|
|
212596
212596
|
this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
|
|
212597
|
-
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
|
|
212597
|
+
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
|
|
212598
212598
|
for (let i = 0; i < 2; i++) {
|
|
212599
212599
|
this.viewport = this.getViewport(0, null);
|
|
212600
212600
|
if (!this.updateForViewport())
|
|
@@ -212746,7 +212746,7 @@ class ViewState {
|
|
|
212746
212746
|
clearHeightChangeFlag();
|
|
212747
212747
|
for (let vp of this.viewports) {
|
|
212748
212748
|
let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
|
|
212749
|
-
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
212749
|
+
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
212750
212750
|
}
|
|
212751
212751
|
if (heightChangeFlag)
|
|
212752
212752
|
result |= 2 /* UpdateFlag.Height */;
|
|
@@ -213932,7 +213932,7 @@ class EditContextManager {
|
|
|
213932
213932
|
let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
|
|
213933
213933
|
if (view.inputState.composing >= 0 && !this.composing)
|
|
213934
213934
|
this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
|
|
213935
|
-
let change = { from, to, insert: Text.of(e.text.split("\n")) };
|
|
213935
|
+
let change = { from, to, insert: Text$1.of(e.text.split("\n")) };
|
|
213936
213936
|
// If the window doesn't include the anchor, assume changes
|
|
213937
213937
|
// adjacent to a side go up to the anchor.
|
|
213938
213938
|
if (change.from == this.from && anchor < this.from)
|
|
@@ -213948,7 +213948,7 @@ class EditContextManager {
|
|
|
213948
213948
|
}
|
|
213949
213949
|
if ((browser.mac || browser.android) && change.from == head - 1 &&
|
|
213950
213950
|
/^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
|
|
213951
|
-
change = { from, to, insert: Text.of([e.text.replace(".", " ")]) };
|
|
213951
|
+
change = { from, to, insert: Text$1.of([e.text.replace(".", " ")]) };
|
|
213952
213952
|
this.pendingContextChange = change;
|
|
213953
213953
|
if (!view.state.readOnly) {
|
|
213954
213954
|
let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
|
|
@@ -223080,7 +223080,7 @@ const splitLine = ({ state, dispatch }) => {
|
|
|
223080
223080
|
if (state.readOnly)
|
|
223081
223081
|
return false;
|
|
223082
223082
|
let changes = state.changeByRange(range => {
|
|
223083
|
-
return { changes: { from: range.from, to: range.to, insert: Text.of(["", ""]) },
|
|
223083
|
+
return { changes: { from: range.from, to: range.to, insert: Text$1.of(["", ""]) },
|
|
223084
223084
|
range: EditorSelection.cursor(range.from) };
|
|
223085
223085
|
});
|
|
223086
223086
|
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
|
|
@@ -223254,7 +223254,7 @@ function newlineAndIndent(atEof) {
|
|
|
223254
223254
|
let insert = ["", indentString(state, indent)];
|
|
223255
223255
|
if (explode)
|
|
223256
223256
|
insert.push(indentString(state, cx.lineIndent(line.from, -1)));
|
|
223257
|
-
return { changes: { from, to, insert: Text.of(insert) },
|
|
223257
|
+
return { changes: { from, to, insert: Text$1.of(insert) },
|
|
223258
223258
|
range: EditorSelection.cursor(from + 1 + insert[1].length) };
|
|
223259
223259
|
});
|
|
223260
223260
|
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
|
|
@@ -229931,7 +229931,7 @@ function snippet(template) {
|
|
|
229931
229931
|
let { text, ranges } = snippet.instantiate(editor.state, from);
|
|
229932
229932
|
let { main } = editor.state.selection;
|
|
229933
229933
|
let spec = {
|
|
229934
|
-
changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
|
|
229934
|
+
changes: { from, to: to == main.from ? main.to : to, insert: Text$1.of(text) },
|
|
229935
229935
|
scrollIntoView: true,
|
|
229936
229936
|
annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
|
|
229937
229937
|
};
|
|
@@ -234951,6 +234951,11 @@ class IdeDiff extends HTMLElement {
|
|
|
234951
234951
|
let asisCursor = 0;
|
|
234952
234952
|
let tobeCursor = 0;
|
|
234953
234953
|
|
|
234954
|
+
// ⭐️ 중요: 새로운 문서 내용을 기반으로 임시 Doc 객체를 생성합니다.
|
|
234955
|
+
// 이 Doc 객체를 사용하여 lineAt()을 호출합니다.
|
|
234956
|
+
const asisDoc = Text.of(asisSrc.split('\n'));
|
|
234957
|
+
const tobeDoc = Text.of(tobeSrc.split('\n'));
|
|
234958
|
+
|
|
234954
234959
|
for (const [op, text] of diffs) {
|
|
234955
234960
|
const len = text.length;
|
|
234956
234961
|
|
|
@@ -234965,17 +234970,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234965
234970
|
let currentTobeLineOffset = tobeCursor;
|
|
234966
234971
|
const tobeLines = text.split('\n');
|
|
234967
234972
|
for (let i = 0; i < tobeLines.length; i++) {
|
|
234968
|
-
//
|
|
234969
|
-
|
|
234970
|
-
|
|
234971
|
-
// 그러나, Effect로 반환되어 트랜잭션에 포함될 때 CodeMirror는
|
|
234972
|
-
// Effect를 처리하는 시점에 이미 텍스트가 업데이트되었음을 보장합니다.
|
|
234973
|
-
// 따라서 여기서 doc.length로 유효성 검사하는 것은 새로운 src2 기준이어야 더 정확합니다.
|
|
234974
|
-
// 하지만, 이 라인은 결국 새로운 doc에서 실행될 것이므로,
|
|
234975
|
-
// 여기서의 this.#tobeEditorView.state.doc.length 검사는 불필요하거나 오해의 소지가 있습니다.
|
|
234976
|
-
// 대신, tobeCursor + len (또는 currentTobeLineOffset)이 tobeSrc의 길이를 벗어나지 않는지 확인하는 것이 좋습니다.
|
|
234977
|
-
if (currentTobeLineOffset < tobeSrc.length) { // src2 (새로운 텍스트)의 길이와 비교
|
|
234978
|
-
const line = this.#tobeEditorView.state.doc.lineAt(currentTobeLineOffset);
|
|
234973
|
+
// ⭐️ this.#tobeEditorView.state.doc 대신 tobeDoc 사용
|
|
234974
|
+
if (currentTobeLineOffset < tobeDoc.length) {
|
|
234975
|
+
const line = tobeDoc.lineAt(currentTobeLineOffset);
|
|
234979
234976
|
tobeLineDecos.push({
|
|
234980
234977
|
from: line.from,
|
|
234981
234978
|
to: line.to,
|
|
@@ -235001,8 +234998,9 @@ class IdeDiff extends HTMLElement {
|
|
|
235001
234998
|
let currentAsisLineOffset = asisCursor;
|
|
235002
234999
|
const asisLines = text.split('\n');
|
|
235003
235000
|
for (let i = 0; i < asisLines.length; i++) {
|
|
235004
|
-
|
|
235005
|
-
|
|
235001
|
+
// ⭐️ this.#asisEditorView.state.doc 대신 asisDoc 사용
|
|
235002
|
+
if (currentAsisLineOffset < asisDoc.length) {
|
|
235003
|
+
const line = asisDoc.lineAt(currentAsisLineOffset);
|
|
235006
235004
|
asisLineDecos.push({
|
|
235007
235005
|
from: line.from,
|
|
235008
235006
|
to: line.to,
|
|
@@ -235054,7 +235052,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235054
235052
|
add: tobeMarkBuilder.finish().children
|
|
235055
235053
|
});
|
|
235056
235054
|
|
|
235057
|
-
// ⭐️ 중요: 데코레이션 효과를 반환합니다. 여기서 직접 dispatch 하지 않습니다.
|
|
235058
235055
|
return {
|
|
235059
235056
|
asisEffect: setAsisDecorationsEffect.of(finalAsisDecorations),
|
|
235060
235057
|
tobeEffect: setTobeDecorationsEffect.of(finalTobeDecorations)
|
package/dist/bundle.esm.js
CHANGED
|
@@ -202476,7 +202476,7 @@ function codePointSize$1(code) { return code < 0x10000 ? 1 : 2 }
|
|
|
202476
202476
|
/**
|
|
202477
202477
|
The data structure for documents. @nonabstract
|
|
202478
202478
|
*/
|
|
202479
|
-
class Text {
|
|
202479
|
+
let Text$1 = class Text {
|
|
202480
202480
|
/**
|
|
202481
202481
|
Get the line description around the given position.
|
|
202482
202482
|
*/
|
|
@@ -202600,11 +202600,11 @@ class Text {
|
|
|
202600
202600
|
return Text.empty;
|
|
202601
202601
|
return text.length <= 32 /* Tree.Branch */ ? new TextLeaf(text) : TextNode.from(TextLeaf.split(text, []));
|
|
202602
202602
|
}
|
|
202603
|
-
}
|
|
202603
|
+
};
|
|
202604
202604
|
// Leaves store an array of line strings. There are always line breaks
|
|
202605
202605
|
// between these strings. Leaves are limited in size and have to be
|
|
202606
202606
|
// contained in TextNode instances for bigger documents.
|
|
202607
|
-
class TextLeaf extends Text {
|
|
202607
|
+
class TextLeaf extends Text$1 {
|
|
202608
202608
|
constructor(text, length = textLength(text)) {
|
|
202609
202609
|
super();
|
|
202610
202610
|
this.text = text;
|
|
@@ -202687,7 +202687,7 @@ class TextLeaf extends Text {
|
|
|
202687
202687
|
// number of other nodes or leaves, taking care to balance themselves
|
|
202688
202688
|
// on changes. There are implied line breaks _between_ the children of
|
|
202689
202689
|
// a node (but not before the first or after the last child).
|
|
202690
|
-
class TextNode extends Text {
|
|
202690
|
+
class TextNode extends Text$1 {
|
|
202691
202691
|
constructor(children, length) {
|
|
202692
202692
|
super();
|
|
202693
202693
|
this.children = children;
|
|
@@ -202823,7 +202823,7 @@ class TextNode extends Text {
|
|
|
202823
202823
|
return chunked.length == 1 ? chunked[0] : new TextNode(chunked, length);
|
|
202824
202824
|
}
|
|
202825
202825
|
}
|
|
202826
|
-
Text.empty = /*@__PURE__*/new TextLeaf([""], 0);
|
|
202826
|
+
Text$1.empty = /*@__PURE__*/new TextLeaf([""], 0);
|
|
202827
202827
|
function textLength(text) {
|
|
202828
202828
|
let length = -1;
|
|
202829
202829
|
for (let line of text)
|
|
@@ -202990,7 +202990,7 @@ class LineCursor {
|
|
|
202990
202990
|
get lineBreak() { return false; }
|
|
202991
202991
|
}
|
|
202992
202992
|
if (typeof Symbol != "undefined") {
|
|
202993
|
-
Text.prototype[Symbol.iterator] = function () { return this.iter(); };
|
|
202993
|
+
Text$1.prototype[Symbol.iterator] = function () { return this.iter(); };
|
|
202994
202994
|
RawTextCursor.prototype[Symbol.iterator] = PartialTextCursor.prototype[Symbol.iterator] =
|
|
202995
202995
|
LineCursor.prototype[Symbol.iterator] = function () { return this; };
|
|
202996
202996
|
}
|
|
@@ -203314,8 +203314,8 @@ class ChangeSet extends ChangeDesc {
|
|
|
203314
203314
|
sections[i + 1] = len;
|
|
203315
203315
|
let index = i >> 1;
|
|
203316
203316
|
while (inserted.length < index)
|
|
203317
|
-
inserted.push(Text.empty);
|
|
203318
|
-
inserted.push(len ? doc.slice(pos, pos + len) : Text.empty);
|
|
203317
|
+
inserted.push(Text$1.empty);
|
|
203318
|
+
inserted.push(len ? doc.slice(pos, pos + len) : Text$1.empty);
|
|
203319
203319
|
}
|
|
203320
203320
|
pos += len;
|
|
203321
203321
|
}
|
|
@@ -203442,7 +203442,7 @@ class ChangeSet extends ChangeDesc {
|
|
|
203442
203442
|
let { from, to = from, insert } = spec;
|
|
203443
203443
|
if (from > to || from < 0 || to > length)
|
|
203444
203444
|
throw new RangeError(`Invalid change range ${from} to ${to} (in doc of length ${length})`);
|
|
203445
|
-
let insText = !insert ? Text.empty : typeof insert == "string" ? Text.of(insert.split(lineSep || DefaultSplit)) : insert;
|
|
203445
|
+
let insText = !insert ? Text$1.empty : typeof insert == "string" ? Text$1.of(insert.split(lineSep || DefaultSplit)) : insert;
|
|
203446
203446
|
let insLen = insText.length;
|
|
203447
203447
|
if (from == to && insLen == 0)
|
|
203448
203448
|
return;
|
|
@@ -203486,8 +203486,8 @@ class ChangeSet extends ChangeDesc {
|
|
|
203486
203486
|
}
|
|
203487
203487
|
else {
|
|
203488
203488
|
while (inserted.length < i)
|
|
203489
|
-
inserted.push(Text.empty);
|
|
203490
|
-
inserted[i] = Text.of(part.slice(1));
|
|
203489
|
+
inserted.push(Text$1.empty);
|
|
203490
|
+
inserted[i] = Text$1.of(part.slice(1));
|
|
203491
203491
|
sections.push(part[0], inserted[i].length);
|
|
203492
203492
|
}
|
|
203493
203493
|
}
|
|
@@ -203524,7 +203524,7 @@ function addInsert(values, sections, value) {
|
|
|
203524
203524
|
}
|
|
203525
203525
|
else {
|
|
203526
203526
|
while (values.length < index)
|
|
203527
|
-
values.push(Text.empty);
|
|
203527
|
+
values.push(Text$1.empty);
|
|
203528
203528
|
values.push(value);
|
|
203529
203529
|
}
|
|
203530
203530
|
}
|
|
@@ -203537,7 +203537,7 @@ function iterChanges(desc, f, individual) {
|
|
|
203537
203537
|
posB += len;
|
|
203538
203538
|
}
|
|
203539
203539
|
else {
|
|
203540
|
-
let endA = posA, endB = posB, text = Text.empty;
|
|
203540
|
+
let endA = posA, endB = posB, text = Text$1.empty;
|
|
203541
203541
|
for (;;) {
|
|
203542
203542
|
endA += len;
|
|
203543
203543
|
endB += ins;
|
|
@@ -203693,11 +203693,11 @@ class SectionIter {
|
|
|
203693
203693
|
get len2() { return this.ins < 0 ? this.len : this.ins; }
|
|
203694
203694
|
get text() {
|
|
203695
203695
|
let { inserted } = this.set, index = (this.i - 2) >> 1;
|
|
203696
|
-
return index >= inserted.length ? Text.empty : inserted[index];
|
|
203696
|
+
return index >= inserted.length ? Text$1.empty : inserted[index];
|
|
203697
203697
|
}
|
|
203698
203698
|
textBit(len) {
|
|
203699
203699
|
let { inserted } = this.set, index = (this.i - 2) >> 1;
|
|
203700
|
-
return index >= inserted.length && !len ? Text.empty
|
|
203700
|
+
return index >= inserted.length && !len ? Text$1.empty
|
|
203701
203701
|
: inserted[index].slice(this.off, len == null ? undefined : this.off + len);
|
|
203702
203702
|
}
|
|
203703
203703
|
forward(len) {
|
|
@@ -205141,7 +205141,7 @@ class EditorState {
|
|
|
205141
205141
|
[`Text`](https://codemirror.net/6/docs/ref/#state.Text) instance from the given string.
|
|
205142
205142
|
*/
|
|
205143
205143
|
toText(string) {
|
|
205144
|
-
return Text.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
|
|
205144
|
+
return Text$1.of(string.split(this.facet(EditorState.lineSeparator) || DefaultSplit));
|
|
205145
205145
|
}
|
|
205146
205146
|
/**
|
|
205147
205147
|
Return the given range of the document as a string.
|
|
@@ -205208,8 +205208,8 @@ class EditorState {
|
|
|
205208
205208
|
*/
|
|
205209
205209
|
static create(config = {}) {
|
|
205210
205210
|
let configuration = Configuration.resolve(config.extensions || [], new Map);
|
|
205211
|
-
let doc = config.doc instanceof Text ? config.doc
|
|
205212
|
-
: Text.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
|
|
205211
|
+
let doc = config.doc instanceof Text$1 ? config.doc
|
|
205212
|
+
: Text$1.of((config.doc || "").split(configuration.staticFacet(EditorState.lineSeparator) || DefaultSplit));
|
|
205213
205213
|
let selection = !config.selection ? EditorSelection.single(0)
|
|
205214
205214
|
: config.selection instanceof EditorSelection ? config.selection
|
|
205215
205215
|
: EditorSelection.single(config.selection.anchor, config.selection.head);
|
|
@@ -207621,12 +207621,12 @@ class WidgetView extends ContentView {
|
|
|
207621
207621
|
ignoreEvent(event) { return this.widget.ignoreEvent(event); }
|
|
207622
207622
|
get overrideDOMText() {
|
|
207623
207623
|
if (this.length == 0)
|
|
207624
|
-
return Text.empty;
|
|
207624
|
+
return Text$1.empty;
|
|
207625
207625
|
let top = this;
|
|
207626
207626
|
while (top.parent)
|
|
207627
207627
|
top = top.parent;
|
|
207628
207628
|
let { view } = top, text = view && view.state.doc, start = this.posAtStart;
|
|
207629
|
-
return text ? text.slice(start, start + this.length) : Text.empty;
|
|
207629
|
+
return text ? text.slice(start, start + this.length) : Text$1.empty;
|
|
207630
207630
|
}
|
|
207631
207631
|
domAtPos(pos) {
|
|
207632
207632
|
return (this.length ? pos == 0 : this.side > 0)
|
|
@@ -207688,7 +207688,7 @@ class WidgetBufferView extends ContentView {
|
|
|
207688
207688
|
return this.dom.getBoundingClientRect();
|
|
207689
207689
|
}
|
|
207690
207690
|
get overrideDOMText() {
|
|
207691
|
-
return Text.empty;
|
|
207691
|
+
return Text$1.empty;
|
|
207692
207692
|
}
|
|
207693
207693
|
get isHidden() { return true; }
|
|
207694
207694
|
}
|
|
@@ -208312,7 +208312,7 @@ class BlockWidgetView extends ContentView {
|
|
|
208312
208312
|
}
|
|
208313
208313
|
}
|
|
208314
208314
|
get overrideDOMText() {
|
|
208315
|
-
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text.empty;
|
|
208315
|
+
return this.parent ? this.parent.view.state.doc.slice(this.posAtStart, this.posAtEnd) : Text$1.empty;
|
|
208316
208316
|
}
|
|
208317
208317
|
domBoundsAround() { return null; }
|
|
208318
208318
|
become(other) {
|
|
@@ -210652,7 +210652,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210652
210652
|
diff.toB == diff.from + 2 && domChange.text.slice(diff.from, diff.toB) == LineBreakPlaceholder + LineBreakPlaceholder)
|
|
210653
210653
|
diff.toB--;
|
|
210654
210654
|
change = { from: from + diff.from, to: from + diff.toA,
|
|
210655
|
-
insert: Text.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
210655
|
+
insert: Text$1.of(domChange.text.slice(diff.from, diff.toB).split(LineBreakPlaceholder)) };
|
|
210656
210656
|
}
|
|
210657
210657
|
}
|
|
210658
210658
|
else if (newSel && (!view.hasFocus && view.state.facet(editable) || newSel.main.eq(sel))) {
|
|
@@ -210670,7 +210670,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210670
210670
|
// and transform it into a regular space insert.
|
|
210671
210671
|
if (newSel && change.insert.length == 2)
|
|
210672
210672
|
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
210673
|
-
change = { from: change.from, to: change.to, insert: Text.of([change.insert.toString().replace(".", " ")]) };
|
|
210673
|
+
change = { from: change.from, to: change.to, insert: Text$1.of([change.insert.toString().replace(".", " ")]) };
|
|
210674
210674
|
}
|
|
210675
210675
|
else if (change && change.from >= sel.from && change.to <= sel.to &&
|
|
210676
210676
|
(change.from != sel.from || change.to != sel.to) &&
|
|
@@ -210690,7 +210690,7 @@ function applyDOMChange(view, domChange) {
|
|
|
210690
210690
|
// bogus new line to be created in CodeMirror (#968)
|
|
210691
210691
|
if (newSel)
|
|
210692
210692
|
newSel = EditorSelection.single(newSel.main.anchor - 1, newSel.main.head - 1);
|
|
210693
|
-
change = { from: sel.from, to: sel.to, insert: Text.of([" "]) };
|
|
210693
|
+
change = { from: sel.from, to: sel.to, insert: Text$1.of([" "]) };
|
|
210694
210694
|
}
|
|
210695
210695
|
if (change) {
|
|
210696
210696
|
return applyDOMChangeInner(view, change, newSel, lastKey);
|
|
@@ -211743,7 +211743,7 @@ function clearHeightChangeFlag() { heightChangeFlag = false; }
|
|
|
211743
211743
|
class HeightOracle {
|
|
211744
211744
|
constructor(lineWrapping) {
|
|
211745
211745
|
this.lineWrapping = lineWrapping;
|
|
211746
|
-
this.doc = Text.empty;
|
|
211746
|
+
this.doc = Text$1.empty;
|
|
211747
211747
|
this.heightSamples = {};
|
|
211748
211748
|
this.lineHeight = 14; // The height of an entire line (line-height)
|
|
211749
211749
|
this.charWidth = 7;
|
|
@@ -212590,7 +212590,7 @@ class ViewState {
|
|
|
212590
212590
|
let guessWrapping = state.facet(contentAttributes).some(v => typeof v != "function" && v.class == "cm-lineWrapping");
|
|
212591
212591
|
this.heightOracle = new HeightOracle(guessWrapping);
|
|
212592
212592
|
this.stateDeco = state.facet(decorations).filter(d => typeof d != "function");
|
|
212593
|
-
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
|
|
212593
|
+
this.heightMap = HeightMap.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle.setDoc(state.doc), [new ChangedRange(0, 0, 0, state.doc.length)]);
|
|
212594
212594
|
for (let i = 0; i < 2; i++) {
|
|
212595
212595
|
this.viewport = this.getViewport(0, null);
|
|
212596
212596
|
if (!this.updateForViewport())
|
|
@@ -212742,7 +212742,7 @@ class ViewState {
|
|
|
212742
212742
|
clearHeightChangeFlag();
|
|
212743
212743
|
for (let vp of this.viewports) {
|
|
212744
212744
|
let heights = vp.from == this.viewport.from ? lineHeights : view.docView.measureVisibleLineHeights(vp);
|
|
212745
|
-
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
212745
|
+
this.heightMap = (refresh ? HeightMap.empty().applyChanges(this.stateDeco, Text$1.empty, this.heightOracle, [new ChangedRange(0, 0, 0, view.state.doc.length)]) : this.heightMap).updateHeight(oracle, 0, refresh, new MeasuredHeights(vp.from, heights));
|
|
212746
212746
|
}
|
|
212747
212747
|
if (heightChangeFlag)
|
|
212748
212748
|
result |= 2 /* UpdateFlag.Height */;
|
|
@@ -213928,7 +213928,7 @@ class EditContextManager {
|
|
|
213928
213928
|
let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
|
|
213929
213929
|
if (view.inputState.composing >= 0 && !this.composing)
|
|
213930
213930
|
this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
|
|
213931
|
-
let change = { from, to, insert: Text.of(e.text.split("\n")) };
|
|
213931
|
+
let change = { from, to, insert: Text$1.of(e.text.split("\n")) };
|
|
213932
213932
|
// If the window doesn't include the anchor, assume changes
|
|
213933
213933
|
// adjacent to a side go up to the anchor.
|
|
213934
213934
|
if (change.from == this.from && anchor < this.from)
|
|
@@ -213944,7 +213944,7 @@ class EditContextManager {
|
|
|
213944
213944
|
}
|
|
213945
213945
|
if ((browser.mac || browser.android) && change.from == head - 1 &&
|
|
213946
213946
|
/^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
|
|
213947
|
-
change = { from, to, insert: Text.of([e.text.replace(".", " ")]) };
|
|
213947
|
+
change = { from, to, insert: Text$1.of([e.text.replace(".", " ")]) };
|
|
213948
213948
|
this.pendingContextChange = change;
|
|
213949
213949
|
if (!view.state.readOnly) {
|
|
213950
213950
|
let newLen = this.to - this.from + (change.to - change.from + change.insert.length);
|
|
@@ -223076,7 +223076,7 @@ const splitLine = ({ state, dispatch }) => {
|
|
|
223076
223076
|
if (state.readOnly)
|
|
223077
223077
|
return false;
|
|
223078
223078
|
let changes = state.changeByRange(range => {
|
|
223079
|
-
return { changes: { from: range.from, to: range.to, insert: Text.of(["", ""]) },
|
|
223079
|
+
return { changes: { from: range.from, to: range.to, insert: Text$1.of(["", ""]) },
|
|
223080
223080
|
range: EditorSelection.cursor(range.from) };
|
|
223081
223081
|
});
|
|
223082
223082
|
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
|
|
@@ -223250,7 +223250,7 @@ function newlineAndIndent(atEof) {
|
|
|
223250
223250
|
let insert = ["", indentString(state, indent)];
|
|
223251
223251
|
if (explode)
|
|
223252
223252
|
insert.push(indentString(state, cx.lineIndent(line.from, -1)));
|
|
223253
|
-
return { changes: { from, to, insert: Text.of(insert) },
|
|
223253
|
+
return { changes: { from, to, insert: Text$1.of(insert) },
|
|
223254
223254
|
range: EditorSelection.cursor(from + 1 + insert[1].length) };
|
|
223255
223255
|
});
|
|
223256
223256
|
dispatch(state.update(changes, { scrollIntoView: true, userEvent: "input" }));
|
|
@@ -229927,7 +229927,7 @@ function snippet(template) {
|
|
|
229927
229927
|
let { text, ranges } = snippet.instantiate(editor.state, from);
|
|
229928
229928
|
let { main } = editor.state.selection;
|
|
229929
229929
|
let spec = {
|
|
229930
|
-
changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
|
|
229930
|
+
changes: { from, to: to == main.from ? main.to : to, insert: Text$1.of(text) },
|
|
229931
229931
|
scrollIntoView: true,
|
|
229932
229932
|
annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
|
|
229933
229933
|
};
|
|
@@ -234947,6 +234947,11 @@ class IdeDiff extends HTMLElement {
|
|
|
234947
234947
|
let asisCursor = 0;
|
|
234948
234948
|
let tobeCursor = 0;
|
|
234949
234949
|
|
|
234950
|
+
// ⭐️ 중요: 새로운 문서 내용을 기반으로 임시 Doc 객체를 생성합니다.
|
|
234951
|
+
// 이 Doc 객체를 사용하여 lineAt()을 호출합니다.
|
|
234952
|
+
const asisDoc = Text.of(asisSrc.split('\n'));
|
|
234953
|
+
const tobeDoc = Text.of(tobeSrc.split('\n'));
|
|
234954
|
+
|
|
234950
234955
|
for (const [op, text] of diffs) {
|
|
234951
234956
|
const len = text.length;
|
|
234952
234957
|
|
|
@@ -234961,17 +234966,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234961
234966
|
let currentTobeLineOffset = tobeCursor;
|
|
234962
234967
|
const tobeLines = text.split('\n');
|
|
234963
234968
|
for (let i = 0; i < tobeLines.length; i++) {
|
|
234964
|
-
//
|
|
234965
|
-
|
|
234966
|
-
|
|
234967
|
-
// 그러나, Effect로 반환되어 트랜잭션에 포함될 때 CodeMirror는
|
|
234968
|
-
// Effect를 처리하는 시점에 이미 텍스트가 업데이트되었음을 보장합니다.
|
|
234969
|
-
// 따라서 여기서 doc.length로 유효성 검사하는 것은 새로운 src2 기준이어야 더 정확합니다.
|
|
234970
|
-
// 하지만, 이 라인은 결국 새로운 doc에서 실행될 것이므로,
|
|
234971
|
-
// 여기서의 this.#tobeEditorView.state.doc.length 검사는 불필요하거나 오해의 소지가 있습니다.
|
|
234972
|
-
// 대신, tobeCursor + len (또는 currentTobeLineOffset)이 tobeSrc의 길이를 벗어나지 않는지 확인하는 것이 좋습니다.
|
|
234973
|
-
if (currentTobeLineOffset < tobeSrc.length) { // src2 (새로운 텍스트)의 길이와 비교
|
|
234974
|
-
const line = this.#tobeEditorView.state.doc.lineAt(currentTobeLineOffset);
|
|
234969
|
+
// ⭐️ this.#tobeEditorView.state.doc 대신 tobeDoc 사용
|
|
234970
|
+
if (currentTobeLineOffset < tobeDoc.length) {
|
|
234971
|
+
const line = tobeDoc.lineAt(currentTobeLineOffset);
|
|
234975
234972
|
tobeLineDecos.push({
|
|
234976
234973
|
from: line.from,
|
|
234977
234974
|
to: line.to,
|
|
@@ -234997,8 +234994,9 @@ class IdeDiff extends HTMLElement {
|
|
|
234997
234994
|
let currentAsisLineOffset = asisCursor;
|
|
234998
234995
|
const asisLines = text.split('\n');
|
|
234999
234996
|
for (let i = 0; i < asisLines.length; i++) {
|
|
235000
|
-
|
|
235001
|
-
|
|
234997
|
+
// ⭐️ this.#asisEditorView.state.doc 대신 asisDoc 사용
|
|
234998
|
+
if (currentAsisLineOffset < asisDoc.length) {
|
|
234999
|
+
const line = asisDoc.lineAt(currentAsisLineOffset);
|
|
235002
235000
|
asisLineDecos.push({
|
|
235003
235001
|
from: line.from,
|
|
235004
235002
|
to: line.to,
|
|
@@ -235050,7 +235048,6 @@ class IdeDiff extends HTMLElement {
|
|
|
235050
235048
|
add: tobeMarkBuilder.finish().children
|
|
235051
235049
|
});
|
|
235052
235050
|
|
|
235053
|
-
// ⭐️ 중요: 데코레이션 효과를 반환합니다. 여기서 직접 dispatch 하지 않습니다.
|
|
235054
235051
|
return {
|
|
235055
235052
|
asisEffect: setAsisDecorationsEffect.of(finalAsisDecorations),
|
|
235056
235053
|
tobeEffect: setTobeDecorationsEffect.of(finalTobeDecorations)
|
|
@@ -224,6 +224,11 @@ export class IdeDiff extends HTMLElement {
|
|
|
224
224
|
let asisCursor = 0;
|
|
225
225
|
let tobeCursor = 0;
|
|
226
226
|
|
|
227
|
+
// ⭐️ 중요: 새로운 문서 내용을 기반으로 임시 Doc 객체를 생성합니다.
|
|
228
|
+
// 이 Doc 객체를 사용하여 lineAt()을 호출합니다.
|
|
229
|
+
const asisDoc = Text.of(asisSrc.split('\n'));
|
|
230
|
+
const tobeDoc = Text.of(tobeSrc.split('\n'));
|
|
231
|
+
|
|
227
232
|
for (const [op, text] of diffs) {
|
|
228
233
|
const len = text.length;
|
|
229
234
|
|
|
@@ -238,17 +243,9 @@ export class IdeDiff extends HTMLElement {
|
|
|
238
243
|
let currentTobeLineOffset = tobeCursor;
|
|
239
244
|
const tobeLines = text.split('\n');
|
|
240
245
|
for (let i = 0; i < tobeLines.length; i++) {
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
// 그러나, Effect로 반환되어 트랜잭션에 포함될 때 CodeMirror는
|
|
245
|
-
// Effect를 처리하는 시점에 이미 텍스트가 업데이트되었음을 보장합니다.
|
|
246
|
-
// 따라서 여기서 doc.length로 유효성 검사하는 것은 새로운 src2 기준이어야 더 정확합니다.
|
|
247
|
-
// 하지만, 이 라인은 결국 새로운 doc에서 실행될 것이므로,
|
|
248
|
-
// 여기서의 this.#tobeEditorView.state.doc.length 검사는 불필요하거나 오해의 소지가 있습니다.
|
|
249
|
-
// 대신, tobeCursor + len (또는 currentTobeLineOffset)이 tobeSrc의 길이를 벗어나지 않는지 확인하는 것이 좋습니다.
|
|
250
|
-
if (currentTobeLineOffset < tobeSrc.length) { // src2 (새로운 텍스트)의 길이와 비교
|
|
251
|
-
const line = this.#tobeEditorView.state.doc.lineAt(currentTobeLineOffset);
|
|
246
|
+
// ⭐️ this.#tobeEditorView.state.doc 대신 tobeDoc 사용
|
|
247
|
+
if (currentTobeLineOffset < tobeDoc.length) {
|
|
248
|
+
const line = tobeDoc.lineAt(currentTobeLineOffset);
|
|
252
249
|
tobeLineDecos.push({
|
|
253
250
|
from: line.from,
|
|
254
251
|
to: line.to,
|
|
@@ -274,8 +271,9 @@ export class IdeDiff extends HTMLElement {
|
|
|
274
271
|
let currentAsisLineOffset = asisCursor;
|
|
275
272
|
const asisLines = text.split('\n');
|
|
276
273
|
for (let i = 0; i < asisLines.length; i++) {
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
// ⭐️ this.#asisEditorView.state.doc 대신 asisDoc 사용
|
|
275
|
+
if (currentAsisLineOffset < asisDoc.length) {
|
|
276
|
+
const line = asisDoc.lineAt(currentAsisLineOffset);
|
|
279
277
|
asisLineDecos.push({
|
|
280
278
|
from: line.from,
|
|
281
279
|
to: line.to,
|
|
@@ -327,7 +325,6 @@ export class IdeDiff extends HTMLElement {
|
|
|
327
325
|
add: tobeMarkBuilder.finish().children
|
|
328
326
|
});
|
|
329
327
|
|
|
330
|
-
// ⭐️ 중요: 데코레이션 효과를 반환합니다. 여기서 직접 dispatch 하지 않습니다.
|
|
331
328
|
return {
|
|
332
329
|
asisEffect: setAsisDecorationsEffect.of(finalAsisDecorations),
|
|
333
330
|
tobeEffect: setTobeDecorationsEffect.of(finalTobeDecorations)
|
package/package.json
CHANGED
|
@@ -224,6 +224,11 @@ export class IdeDiff extends HTMLElement {
|
|
|
224
224
|
let asisCursor = 0;
|
|
225
225
|
let tobeCursor = 0;
|
|
226
226
|
|
|
227
|
+
// ⭐️ 중요: 새로운 문서 내용을 기반으로 임시 Doc 객체를 생성합니다.
|
|
228
|
+
// 이 Doc 객체를 사용하여 lineAt()을 호출합니다.
|
|
229
|
+
const asisDoc = Text.of(asisSrc.split('\n'));
|
|
230
|
+
const tobeDoc = Text.of(tobeSrc.split('\n'));
|
|
231
|
+
|
|
227
232
|
for (const [op, text] of diffs) {
|
|
228
233
|
const len = text.length;
|
|
229
234
|
|
|
@@ -238,17 +243,9 @@ export class IdeDiff extends HTMLElement {
|
|
|
238
243
|
let currentTobeLineOffset = tobeCursor;
|
|
239
244
|
const tobeLines = text.split('\n');
|
|
240
245
|
for (let i = 0; i < tobeLines.length; i++) {
|
|
241
|
-
//
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
// 그러나, Effect로 반환되어 트랜잭션에 포함될 때 CodeMirror는
|
|
245
|
-
// Effect를 처리하는 시점에 이미 텍스트가 업데이트되었음을 보장합니다.
|
|
246
|
-
// 따라서 여기서 doc.length로 유효성 검사하는 것은 새로운 src2 기준이어야 더 정확합니다.
|
|
247
|
-
// 하지만, 이 라인은 결국 새로운 doc에서 실행될 것이므로,
|
|
248
|
-
// 여기서의 this.#tobeEditorView.state.doc.length 검사는 불필요하거나 오해의 소지가 있습니다.
|
|
249
|
-
// 대신, tobeCursor + len (또는 currentTobeLineOffset)이 tobeSrc의 길이를 벗어나지 않는지 확인하는 것이 좋습니다.
|
|
250
|
-
if (currentTobeLineOffset < tobeSrc.length) { // src2 (새로운 텍스트)의 길이와 비교
|
|
251
|
-
const line = this.#tobeEditorView.state.doc.lineAt(currentTobeLineOffset);
|
|
246
|
+
// ⭐️ this.#tobeEditorView.state.doc 대신 tobeDoc 사용
|
|
247
|
+
if (currentTobeLineOffset < tobeDoc.length) {
|
|
248
|
+
const line = tobeDoc.lineAt(currentTobeLineOffset);
|
|
252
249
|
tobeLineDecos.push({
|
|
253
250
|
from: line.from,
|
|
254
251
|
to: line.to,
|
|
@@ -274,8 +271,9 @@ export class IdeDiff extends HTMLElement {
|
|
|
274
271
|
let currentAsisLineOffset = asisCursor;
|
|
275
272
|
const asisLines = text.split('\n');
|
|
276
273
|
for (let i = 0; i < asisLines.length; i++) {
|
|
277
|
-
|
|
278
|
-
|
|
274
|
+
// ⭐️ this.#asisEditorView.state.doc 대신 asisDoc 사용
|
|
275
|
+
if (currentAsisLineOffset < asisDoc.length) {
|
|
276
|
+
const line = asisDoc.lineAt(currentAsisLineOffset);
|
|
279
277
|
asisLineDecos.push({
|
|
280
278
|
from: line.from,
|
|
281
279
|
to: line.to,
|
|
@@ -327,7 +325,6 @@ export class IdeDiff extends HTMLElement {
|
|
|
327
325
|
add: tobeMarkBuilder.finish().children
|
|
328
326
|
});
|
|
329
327
|
|
|
330
|
-
// ⭐️ 중요: 데코레이션 효과를 반환합니다. 여기서 직접 dispatch 하지 않습니다.
|
|
331
328
|
return {
|
|
332
329
|
asisEffect: setAsisDecorationsEffect.of(finalAsisDecorations),
|
|
333
330
|
tobeEffect: setTobeDecorationsEffect.of(finalTobeDecorations)
|