提交 de15217a 编写于 作者: J Johannes Rieken

fix off by one issue, #16277

上级 ff1991b7
......@@ -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}']);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册