mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 21:55:38 +00:00
Fixes #90135: Consider that undo edits might also contain auto trim whitespace edits
This commit is contained in:
parent
aeafeb8a12
commit
6aefd70de8
|
@ -468,6 +468,7 @@ export class SnippetSession {
|
|||
// that ensures the primiary cursor stays primary despite not being
|
||||
// the one with lowest start position
|
||||
edits[idx] = EditOperation.replace(snippetSelection, snippet.toString());
|
||||
edits[idx].identifier = { major: idx, minor: 0 }; // mark the edit so only our undo edits will be used to generate end cursors
|
||||
snippets[idx] = new OneSnippet(editor, snippet, offset);
|
||||
}
|
||||
|
||||
|
@ -507,7 +508,11 @@ export class SnippetSession {
|
|||
if (this._snippets[0].hasPlaceholder) {
|
||||
return this._move(true);
|
||||
} else {
|
||||
return undoEdits.map(edit => Selection.fromPositions(edit.range.getEndPosition()));
|
||||
return (
|
||||
undoEdits
|
||||
.filter(edit => !!edit.identifier) // only use our undo edits
|
||||
.map(edit => Selection.fromPositions(edit.range.getEndPosition()))
|
||||
);
|
||||
}
|
||||
});
|
||||
this._editor.revealRange(this._editor.getSelections()[0]);
|
||||
|
@ -529,7 +534,11 @@ export class SnippetSession {
|
|||
if (this._snippets[0].hasPlaceholder) {
|
||||
return this._move(undefined);
|
||||
} else {
|
||||
return undoEdits.map(edit => Selection.fromPositions(edit.range.getEndPosition()));
|
||||
return (
|
||||
undoEdits
|
||||
.filter(edit => !!edit.identifier) // only use our undo edits
|
||||
.map(edit => Selection.fromPositions(edit.range.getEndPosition()))
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import { MockContextKeyService } from 'vs/platform/keybinding/test/common/mockKe
|
|||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { NullLogService } from 'vs/platform/log/common/log';
|
||||
import { Handler } from 'vs/editor/common/editorCommon';
|
||||
import { CoreEditingCommands } from 'vs/editor/browser/controller/coreCommands';
|
||||
|
||||
suite('SnippetController2', function () {
|
||||
|
||||
|
@ -428,4 +429,13 @@ suite('SnippetController2', function () {
|
|||
assertSelections(editor, new Selection(2, 5, 2, 5));
|
||||
assertContextKeys(contextKeys, false, false, false);
|
||||
});
|
||||
|
||||
test('issue #90135: confusing trim whitespace edits', function () {
|
||||
const ctrl = new SnippetController2(editor, logService, contextKeys);
|
||||
model.setValue('');
|
||||
CoreEditingCommands.Tab.runEditorCommand(null, editor, null);
|
||||
|
||||
ctrl.insert('\nfoo');
|
||||
assertSelections(editor, new Selection(2, 8, 2, 8));
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue