mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
parent
4a3c073d9e
commit
205e4e53a1
|
@ -272,7 +272,7 @@ export function extendDiffsToEntireWordIfAppropriate(sequence1: LinesSliceCharSe
|
|||
}
|
||||
|
||||
if (equalChars1 + equalChars2 < (w.seq1Range.length + w.seq2Range.length) * 2 / 3) {
|
||||
additional.push(new SequenceDiff(w1, w2));
|
||||
additional.push(w);
|
||||
}
|
||||
|
||||
lastPoint = w.getEndExclusives();
|
||||
|
|
13
src/vs/editor/test/node/diffing/fixtures/issue-201713/1.tst
Normal file
13
src/vs/editor/test/node/diffing/fixtures/issue-201713/1.tst
Normal file
|
@ -0,0 +1,13 @@
|
|||
const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;
|
||||
if (deletedCodeLineBreaksComputer) {
|
||||
for (const a of alignmentsVal) {
|
||||
if (a.diff) {
|
||||
for (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {
|
||||
deletedCodeLineBreaksComputer?.addRequest(this._editors.original.getModel()!.getLineContent(i), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];
|
||||
let lineBreakDataIdx = 0;
|
20
src/vs/editor/test/node/diffing/fixtures/issue-201713/2.tst
Normal file
20
src/vs/editor/test/node/diffing/fixtures/issue-201713/2.tst
Normal file
|
@ -0,0 +1,20 @@
|
|||
const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;
|
||||
if (deletedCodeLineBreaksComputer) {
|
||||
const originalModel = this._editors.original.getModel()!;
|
||||
for (const a of alignmentsVal) {
|
||||
if (a.diff) {
|
||||
for (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {
|
||||
// `i` can be out of bound when the diff has not been updated yet.
|
||||
// In this case, we do an early return.
|
||||
// TODO@hediet: Fix this by applying the edit directly to the diff model, so that the diff is always valid.
|
||||
if (i > originalModel.getLineCount()) {
|
||||
return { orig: origViewZones, mod: modViewZones };
|
||||
}
|
||||
deletedCodeLineBreaksComputer?.addRequest(originalModel.getLineContent(i), null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];
|
||||
let lineBreakDataIdx = 0;
|
|
@ -0,0 +1,44 @@
|
|||
{
|
||||
"original": {
|
||||
"content": "const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;\nif (deletedCodeLineBreaksComputer) {\n\tfor (const a of alignmentsVal) {\n\t\tif (a.diff) {\n\t\t\tfor (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {\n\t\t\t\tdeletedCodeLineBreaksComputer?.addRequest(this._editors.original.getModel()!.getLineContent(i), null, null);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];\nlet lineBreakDataIdx = 0;",
|
||||
"fileName": "./1.tst"
|
||||
},
|
||||
"modified": {
|
||||
"content": "const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;\nif (deletedCodeLineBreaksComputer) {\n\tconst originalModel = this._editors.original.getModel()!;\n\tfor (const a of alignmentsVal) {\n\t\tif (a.diff) {\n\t\t\tfor (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {\n\t\t\t\t// `i` can be out of bound when the diff has not been updated yet.\n\t\t\t\t// In this case, we do an early return.\n\t\t\t\t// TODO@hediet: Fix this by applying the edit directly to the diff model, so that the diff is always valid.\n\t\t\t\tif (i > originalModel.getLineCount()) {\n\t\t\t\t\treturn { orig: origViewZones, mod: modViewZones };\n\t\t\t\t}\n\t\t\t\tdeletedCodeLineBreaksComputer?.addRequest(originalModel.getLineContent(i), null, null);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];\nlet lineBreakDataIdx = 0;",
|
||||
"fileName": "./2.tst"
|
||||
},
|
||||
"diffs": [
|
||||
{
|
||||
"originalRange": "[3,3)",
|
||||
"modifiedRange": "[3,4)",
|
||||
"innerChanges": [
|
||||
{
|
||||
"originalRange": "[3,1 -> 3,1]",
|
||||
"modifiedRange": "[3,1 -> 4,1]"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,7)",
|
||||
"modifiedRange": "[7,14)",
|
||||
"innerChanges": [
|
||||
{
|
||||
"originalRange": "[6,1 -> 6,34]",
|
||||
"modifiedRange": "[7,1 -> 13,34]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,47 -> 6,61]",
|
||||
"modifiedRange": "[13,47 -> 13,47]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,69 -> 6,73]",
|
||||
"modifiedRange": "[13,55 -> 13,55]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,78 -> 6,81]",
|
||||
"modifiedRange": "[13,60 -> 13,60]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"original": {
|
||||
"content": "const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;\nif (deletedCodeLineBreaksComputer) {\n\tfor (const a of alignmentsVal) {\n\t\tif (a.diff) {\n\t\t\tfor (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {\n\t\t\t\tdeletedCodeLineBreaksComputer?.addRequest(this._editors.original.getModel()!.getLineContent(i), null, null);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];\nlet lineBreakDataIdx = 0;",
|
||||
"fileName": "./1.tst"
|
||||
},
|
||||
"modified": {
|
||||
"content": "const deletedCodeLineBreaksComputer = !renderSideBySide ? this._editors.modified._getViewModel()?.createLineBreaksComputer() : undefined;\nif (deletedCodeLineBreaksComputer) {\n\tconst originalModel = this._editors.original.getModel()!;\n\tfor (const a of alignmentsVal) {\n\t\tif (a.diff) {\n\t\t\tfor (let i = a.originalRange.startLineNumber; i < a.originalRange.endLineNumberExclusive; i++) {\n\t\t\t\t// `i` can be out of bound when the diff has not been updated yet.\n\t\t\t\t// In this case, we do an early return.\n\t\t\t\t// TODO@hediet: Fix this by applying the edit directly to the diff model, so that the diff is always valid.\n\t\t\t\tif (i > originalModel.getLineCount()) {\n\t\t\t\t\treturn { orig: origViewZones, mod: modViewZones };\n\t\t\t\t}\n\t\t\t\tdeletedCodeLineBreaksComputer?.addRequest(originalModel.getLineContent(i), null, null);\n\t\t\t}\n\t\t}\n\t}\n}\n\nconst lineBreakData = deletedCodeLineBreaksComputer?.finalize() ?? [];\nlet lineBreakDataIdx = 0;",
|
||||
"fileName": "./2.tst"
|
||||
},
|
||||
"diffs": [
|
||||
{
|
||||
"originalRange": "[3,3)",
|
||||
"modifiedRange": "[3,4)",
|
||||
"innerChanges": null
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,7)",
|
||||
"modifiedRange": "[7,14)",
|
||||
"innerChanges": [
|
||||
{
|
||||
"originalRange": "[6,1 -> 6,1]",
|
||||
"modifiedRange": "[7,1 -> 13,1]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,47 -> 6,61]",
|
||||
"modifiedRange": "[13,47 -> 13,47]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,69 -> 6,73]",
|
||||
"modifiedRange": "[13,55 -> 13,55]"
|
||||
},
|
||||
{
|
||||
"originalRange": "[6,78 -> 6,81]",
|
||||
"modifiedRange": "[13,60 -> 13,60]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -75,7 +75,7 @@
|
|||
"modifiedRange": "[23,25)",
|
||||
"innerChanges": [
|
||||
{
|
||||
"originalRange": "[25,9 -> 26,13]",
|
||||
"originalRange": "[25,9 -> 26,18]",
|
||||
"modifiedRange": "[23,9 -> 23,18]"
|
||||
},
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@
|
|||
"innerChanges": [
|
||||
{
|
||||
"originalRange": "[53,8 -> 53,17]",
|
||||
"modifiedRange": "[53,8 -> 53,28]"
|
||||
"modifiedRange": "[53,8 -> 53,31]"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue