Skip to content

Commit 36b7d5b

Browse files
authored
1 parent 7515bfd commit 36b7d5b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/vs/workbench/contrib/mergeEditor/browser/model/mapping.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,23 @@ export class DetailedLineRangeMapping extends LineRangeMapping {
240240

241241
assertFn(() => {
242242
for (const map of this.rangeMappings) {
243-
const inputRangesValid =
244-
inputRange.startLineNumber <= map.inputRange.startLineNumber
245-
&& map.inputRange.endLineNumber <= inputRange.endLineNumberExclusive
246-
&& (map.inputRange.endLineNumber !== inputRange.endLineNumberExclusive || map.inputRange.endColumn === 1);
247-
248-
const outputRangesValid = outputRange.startLineNumber <= map.outputRange.startLineNumber
249-
&& map.outputRange.endLineNumber <= outputRange.endLineNumberExclusive
250-
&& (map.outputRange.endLineNumber !== outputRange.endLineNumberExclusive || map.outputRange.endColumn === 1);
243+
let inputRangesValid = inputRange.startLineNumber - 1 <= map.inputRange.startLineNumber
244+
&& map.inputRange.endLineNumber <= inputRange.endLineNumberExclusive;
245+
if (inputRangesValid && map.inputRange.startLineNumber === inputRange.startLineNumber - 1) {
246+
inputRangesValid = map.inputRange.endColumn >= inputTextModel.getLineMaxColumn(map.inputRange.startLineNumber);
247+
}
248+
if (inputRangesValid && map.inputRange.endLineNumber === inputRange.endLineNumberExclusive) {
249+
inputRangesValid = map.inputRange.endColumn === 1;
250+
}
251+
252+
let outputRangesValid = outputRange.startLineNumber - 1 <= map.outputRange.startLineNumber
253+
&& map.outputRange.endLineNumber <= outputRange.endLineNumberExclusive;
254+
if (outputRangesValid && map.outputRange.startLineNumber === outputRange.startLineNumber - 1) {
255+
outputRangesValid = map.outputRange.endColumn >= outputTextModel.getLineMaxColumn(map.outputRange.startLineNumber);
256+
}
257+
if (outputRangesValid && map.outputRange.endLineNumber === outputRange.endLineNumberExclusive) {
258+
outputRangesValid = map.outputRange.endColumn === 1;
259+
}
251260

252261
if (!inputRangesValid || !outputRangesValid) {
253262
return false;

src/vs/workbench/contrib/mergeEditor/browser/model/modifiedBaseRange.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ function editsToLineRangeEdit(range: LineRange, sortedEdits: RangeEdit[], textMo
206206
let currentPosition = startsLineBefore
207207
? new Position(
208208
range.startLineNumber - 1,
209-
Constants.MAX_SAFE_SMALL_INTEGER
209+
textModel.getLineMaxColumn(range.startLineNumber - 1)
210210
)
211211
: new Position(range.startLineNumber, 1);
212212

0 commit comments

Comments
 (0)