提交 1842f05e 编写于 作者: A Alex Dima

Fixes #3090: Attempt first line again at the end when finding next or previous matches

上级 875d0905
......@@ -880,7 +880,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
return r;
}
for (var i = 1; i < lineCount; i++) {
for (var i = 1; i <= lineCount; i++) {
var lineIndex = (startLineNumber + i - 1) % lineCount;
text = this._lines[lineIndex].text;
r = this._findMatchInLine(regex, text, lineIndex + 1, 0);
......@@ -915,7 +915,7 @@ export class TextModel extends OrderGuaranteeEventEmitter implements editorCommo
return r;
}
for (var i = 1; i < lineCount; i++) {
for (var i = 1; i <= lineCount; i++) {
var lineIndex = (lineCount + startLineNumber - i - 1) % lineCount;
text = this._lines[lineIndex].text;
r = this._findLastMatchInLine(regex, text, lineIndex + 1);
......
......@@ -88,4 +88,29 @@ suite('FindController', () => {
nextMatchFindAction.dispose();
});
});
test('issue #3090: F3 does not loop with two matches on a single line', () => {
withMockCodeEditor([
'import nls = require(\'vs/nls\');'
], {}, (editor, cursor) => {
// The cursor is at the very top, of the file, at the first ABC
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let nextMatchFindAction = new NextMatchFindAction({id:'',label:''}, editor, null);
editor.setPosition({
lineNumber: 1,
column: 9
});
nextMatchFindAction.run();
assert.deepEqual(fromRange(editor.getSelection()), [1, 26, 1, 29]);
nextMatchFindAction.run();
assert.deepEqual(fromRange(editor.getSelection()), [1, 8, 1, 11]);
findController.dispose();
nextMatchFindAction.dispose();
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册