mirror of
https://github.com/Microsoft/vscode
synced 2024-11-05 18:29:38 +00:00
fix off by one issue, #16277
This commit is contained in:
parent
ff1991b789
commit
de15217aee
2 changed files with 17 additions and 2 deletions
|
@ -377,12 +377,12 @@ class BeforeAfterData {
|
|||
|
||||
let contentBefore = '';
|
||||
if (overwriteBefore > 0) {
|
||||
contentBefore = model.getLineContent(selection.startLineNumber).substring(selection.startColumn - 1 - overwriteBefore, selection.startColumn);
|
||||
contentBefore = model.getLineContent(selection.startLineNumber).substring(selection.startColumn - 1 - overwriteBefore, selection.startColumn - 1);
|
||||
}
|
||||
|
||||
let contentAfter = '';
|
||||
if (overwriteAfter > 0) {
|
||||
contentAfter = model.getLineContent(selection.endLineNumber).substring(selection.endColumn - 1, selection.endColumn + overwriteAfter);
|
||||
contentAfter = model.getLineContent(selection.endLineNumber).substring(selection.endColumn - 1, selection.endColumn - 1 + overwriteAfter);
|
||||
}
|
||||
|
||||
return new BeforeAfterData(model, contentBefore, contentAfter, overwriteBefore, overwriteAfter);
|
||||
|
|
|
@ -506,4 +506,19 @@ suite('SnippetController', () => {
|
|||
}, ['this._', 'abc', 'def._']);
|
||||
|
||||
});
|
||||
|
||||
test('Multiple cursor and overwriteBefore/After, #16277', () => {
|
||||
snippetTest((editor, cursor, codeSnippet, controller) => {
|
||||
|
||||
editor.setSelections([
|
||||
new Selection(1, 5, 1, 5),
|
||||
new Selection(2, 5, 2, 5),
|
||||
]);
|
||||
|
||||
codeSnippet = CodeSnippet.fromTextmate('document');
|
||||
controller.run(codeSnippet, 3, 0);
|
||||
assert.equal(editor.getModel().getValue(), '{document}\n{document && true}');
|
||||
|
||||
}, ['{foo}', '{foo && true}']);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue