Skip to content

Commit df8f331

Browse files
Merge branch 'main' into traffic-lights-position
2 parents 35189f0 + 35ca2b7 commit df8f331

File tree

15 files changed

+398
-231
lines changed

15 files changed

+398
-231
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
},
9999
"devDependencies": {
100100
"7zip": "0.0.6",
101-
"@playwright/test": "1.26.0",
101+
"@playwright/test": "1.27.1",
102102
"@swc/cli": "0.1.57",
103103
"@swc/core": "1.2.245",
104104
"@types/cookie": "^0.3.3",
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { ISequence, OffsetRange, SequenceDiff } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
7+
8+
/**
9+
* This function fixes issues like this:
10+
* ```
11+
* import { Baz, Bar } from "foo";
12+
* ```
13+
* <->
14+
* ```
15+
* import { Baz, Bar, Foo } from "foo";
16+
* ```
17+
* Computed diff: [ {Add "," after Bar}, {Add "Foo " after space} }
18+
* Improved diff: [{Add ", Foo" after Bar}]
19+
*/
20+
export function joinSequenceDiffs(sequence1: ISequence, sequence2: ISequence, sequenceDiffs: SequenceDiff[]): SequenceDiff[] {
21+
const result: SequenceDiff[] = [];
22+
if (sequenceDiffs.length > 0) {
23+
result.push(sequenceDiffs[0]);
24+
}
25+
26+
for (let i = 1; i < sequenceDiffs.length; i++) {
27+
const lastResult = result[result.length - 1];
28+
const cur = sequenceDiffs[i];
29+
30+
if (cur.seq1Range.start - lastResult.seq1Range.endExclusive === 1) {
31+
if (cur.seq1Range.isEmpty) {
32+
if (sequence2.getElement(cur.seq2Range.start - 1) === sequence2.getElement(cur.seq2Range.endExclusive - 1)) {
33+
result[result.length - 1] = new SequenceDiff(lastResult.seq1Range, new OffsetRange(
34+
lastResult.seq2Range.start,
35+
cur.seq2Range.endExclusive - 1
36+
));
37+
continue;
38+
}
39+
}
40+
}
41+
42+
result.push(cur);
43+
}
44+
45+
return result;
46+
}

src/vs/editor/common/diff/standardLinesDiffComputer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Position } from 'vs/editor/common/core/position';
88
import { Range } from 'vs/editor/common/core/range';
99
import { SequenceFromIntArray, OffsetRange, SequenceDiff, ISequence } from 'vs/editor/common/diff/algorithms/diffAlgorithm';
1010
import { DynamicProgrammingDiffing } from 'vs/editor/common/diff/algorithms/dynamicProgrammingDiffing';
11+
import { joinSequenceDiffs } from 'vs/editor/common/diff/algorithms/joinSequenceDiffs';
1112
import { MyersDiffAlgorithm } from 'vs/editor/common/diff/algorithms/myersDiffAlgorithm';
1213
import { ILinesDiff, ILinesDiffComputer, ILinesDiffComputerOptions, LineRange, LineRangeMapping, RangeMapping } from 'vs/editor/common/diff/linesDiffComputer';
1314

@@ -108,7 +109,8 @@ export class StandardLinesDiffComputer implements ILinesDiffComputer {
108109
const sourceSlice = new Slice(originalLines, diff.seq1Range);
109110
const targetSlice = new Slice(modifiedLines, diff.seq2Range);
110111

111-
const diffs = this.myersDiffingAlgorithm.compute(sourceSlice, targetSlice);
112+
const originalDiffs = this.myersDiffingAlgorithm.compute(sourceSlice, targetSlice);
113+
const diffs = joinSequenceDiffs(sourceSlice, targetSlice, originalDiffs);
112114
const result = diffs.map(
113115
(d) =>
114116
new RangeMapping(

src/vs/editor/test/common/diff/standardLinesDiffCompute.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ suite('standardLinesDiffCompute', () => {
8585
{
8686
main: "{[5,6)->[5,8)}",
8787
inner: [
88-
"{[5,41 -> 5,41]->[5,41 -> 5,42]}",
89-
"{[6,1 -> 6,1]->[6,1 -> 8,1]}",
88+
"{[5,41 -> 5,41]->[5,41 -> 7,28]}"
9089
]
9190
}
9291
]

src/vs/platform/action/common/action.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ export interface ICommandAction {
7272
* or define toggle-info including an icon and a title that goes well with a checkmark.
7373
*/
7474
toggled?: ContextKeyExpression | ICommandActionToggleInfo;
75-
76-
/** @deprecated see https://github.com/microsoft/vscode/issues/162004 */
77-
_isFakeAction?: true;
7875
}
7976

8077
export type ISerializableCommandAction = UriDto<ICommandAction>;

src/vs/platform/actions/common/actions.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,6 @@ interface IAction2CommonOptions extends ICommandAction {
556556
* showing keybindings that have no other UX.
557557
*/
558558
description?: ICommandHandlerDescription;
559-
560-
/**
561-
* @deprecated workaround added for https://github.com/microsoft/vscode/issues/162004
562-
* This action doesn't do anything is just a workaround for rendering "something"
563-
* inside a specific toolbar
564-
*/
565-
_isFakeAction?: true;
566559
}
567560

568561
interface IBaseAction2Options extends IAction2CommonOptions {

src/vs/platform/actions/common/menuService.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,7 @@ class MenuInfo {
228228
const menuHide = createMenuHide(this._id, isMenuItem ? item.command : item, this._hiddenStates);
229229
if (isMenuItem) {
230230
// MenuItemAction
231-
const actualMenuHide = item.command._isFakeAction ? undefined : menuHide;
232-
activeActions.push(new MenuItemAction(item.command, item.alt, options, actualMenuHide, this._contextKeyService, this._commandService));
231+
activeActions.push(new MenuItemAction(item.command, item.alt, options, menuHide, this._contextKeyService, this._commandService));
233232

234233
} else {
235234
// SubmenuItemAction

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { LineRange } from 'vs/workbench/contrib/mergeEditor/browser/model/lineRa
1616
import { DetailedLineRangeMapping, DocumentLineRangeMap, DocumentRangeMap, LineRangeMapping } from 'vs/workbench/contrib/mergeEditor/browser/model/mapping';
1717
import { TextModelDiffChangeReason, TextModelDiffs, TextModelDiffState } from 'vs/workbench/contrib/mergeEditor/browser/model/textModelDiffs';
1818
import { leftJoin } from 'vs/workbench/contrib/mergeEditor/browser/utils';
19-
import { ModifiedBaseRange, ModifiedBaseRangeState } from './modifiedBaseRange';
19+
import { ModifiedBaseRange, ModifiedBaseRangeState, ModifiedBaseRangeStateKind } from './modifiedBaseRange';
2020

2121
export interface InputData {
2222
readonly textModel: ITextModel;
@@ -41,7 +41,7 @@ export class MergeEditorModel extends EditorModel {
4141
this.modifiedBaseRanges.read(reader).map((s) => [
4242
s,
4343
{
44-
accepted: observableValue(`BaseRangeState${s.baseRange}`, ModifiedBaseRangeState.default),
44+
accepted: observableValue(`BaseRangeState${s.baseRange}`, ModifiedBaseRangeState.base),
4545
handled: observableValue(`BaseRangeHandledState${s.baseRange}`, false),
4646
}
4747
])
@@ -105,7 +105,7 @@ export class MergeEditorModel extends EditorModel {
105105
shouldRecomputeHandledFromAccepted = false;
106106
for (const [_range, observableState] of states) {
107107
const state = observableState.accepted.get();
108-
observableState.handled.set(!(state.isEmpty || state.conflicting), tx);
108+
observableState.handled.set(!(state.kind === ModifiedBaseRangeStateKind.base || state.kind === ModifiedBaseRangeStateKind.unrecognized), tx);
109109
}
110110
}
111111
});
@@ -132,13 +132,13 @@ export class MergeEditorModel extends EditorModel {
132132
let newState: ModifiedBaseRangeState;
133133
let handled = false;
134134
if (range.input1Diffs.length === 0) {
135-
newState = ModifiedBaseRangeState.default.withInput2(true);
135+
newState = ModifiedBaseRangeState.base.withInputValue(2, true);
136136
handled = true;
137137
} else if (range.input2Diffs.length === 0) {
138-
newState = ModifiedBaseRangeState.default.withInput1(true);
138+
newState = ModifiedBaseRangeState.base.withInputValue(1, true);
139139
handled = true;
140140
} else {
141-
newState = ModifiedBaseRangeState.default;
141+
newState = ModifiedBaseRangeState.base;
142142
handled = false;
143143
}
144144

@@ -335,7 +335,7 @@ export class MergeEditorModel extends EditorModel {
335335

336336
private computeState(baseRange: ModifiedBaseRange, conflictingDiffs: DetailedLineRangeMapping[]): ModifiedBaseRangeState {
337337
if (conflictingDiffs.length === 0) {
338-
return ModifiedBaseRangeState.default;
338+
return ModifiedBaseRangeState.base;
339339
}
340340
const conflictingEdits = conflictingDiffs.map((d) => d.getLineEdit());
341341

@@ -348,15 +348,15 @@ export class MergeEditorModel extends EditorModel {
348348
}
349349

350350
if (editsAgreeWithDiffs(baseRange.input1Diffs)) {
351-
return ModifiedBaseRangeState.default.withInput1(true);
351+
return ModifiedBaseRangeState.base.withInputValue(1, true);
352352
}
353353
if (editsAgreeWithDiffs(baseRange.input2Diffs)) {
354-
return ModifiedBaseRangeState.default.withInput2(true);
354+
return ModifiedBaseRangeState.base.withInputValue(2, true);
355355
}
356356

357357
const states = [
358-
ModifiedBaseRangeState.default.withInput1(true).withInput2(true),
359-
ModifiedBaseRangeState.default.withInput2(true).withInput1(true),
358+
ModifiedBaseRangeState.base.withInputValue(1, true).withInputValue(2, true),
359+
ModifiedBaseRangeState.base.withInputValue(2, true).withInputValue(1, true),
360360
];
361361

362362
for (const s of states) {
@@ -371,7 +371,7 @@ export class MergeEditorModel extends EditorModel {
371371
}
372372
}
373373

374-
return ModifiedBaseRangeState.conflicting;
374+
return ModifiedBaseRangeState.unrecognized;
375375
}
376376

377377
public getState(baseRange: ModifiedBaseRange): IObservable<ModifiedBaseRangeState> {
@@ -429,8 +429,8 @@ export class MergeEditorModel extends EditorModel {
429429
/** @description Reset Unknown Base Range States */
430430
this.resultTextModel.pushStackElement();
431431
for (const range of this.modifiedBaseRanges.get()) {
432-
if (this.getState(range).get().conflicting) {
433-
this.setState(range, ModifiedBaseRangeState.default, false, tx, false);
432+
if (this.getState(range).get().kind === ModifiedBaseRangeStateKind.unrecognized) {
433+
this.setState(range, ModifiedBaseRangeState.base, false, tx, false);
434434
}
435435
}
436436
this.resultTextModel.pushStackElement();
@@ -515,7 +515,7 @@ export class MergeEditorModel extends EditorModel {
515515
resultStartLineNumber = resultRange.endLineNumberExclusive;
516516

517517
outputLines.push('<<<<<<<');
518-
if (state.accepted.get().conflicting) {
518+
if (state.accepted.get().kind === ModifiedBaseRangeStateKind.unrecognized) {
519519
// to prevent loss of data, use modified result as "ours"
520520
appendLinesToResult(resultLines, resultRange);
521521
} else {

0 commit comments

Comments
 (0)