提交 b5fff271 编写于 作者: A Alex Dima

Fixes #5400

上级 1d2d9fe4
......@@ -803,16 +803,31 @@ export class MoveSelectionToPreviousFindMatchAction extends SelectPreviousFindMa
export abstract class AbstractSelectHighlightsAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
let r = multiCursorFind(editor, {
changeFindSearchString: true,
allowMultiline: true,
highlightFindOptions: true
});
if (!r) {
return;
let controller = CommonFindController.get(editor);
if (!controller) {
return null;
}
let matches = editor.getModel().findMatches(r.searchText, true, false, r.matchCase, r.wholeWord, false).map(m => m.range);
let matches: Range[] = null;
const findState = controller.getState();
if (findState.isRegex && findState.searchString.length > 0) {
matches = editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord, false).map(m => m.range);
} else {
let r = multiCursorFind(editor, {
changeFindSearchString: true,
allowMultiline: true,
highlightFindOptions: true
});
if (!r) {
return;
}
matches = editor.getModel().findMatches(r.searchText, true, false, r.matchCase, r.wholeWord, false).map(m => m.range);
}
if (matches.length > 0) {
let editorSelection = editor.getSelection();
......
......@@ -215,6 +215,33 @@ suite('FindController', () => {
});
});
test('issue #5400: "Select All Occurences of Find Match" does not select all if find uses regex', () => {
withMockCodeEditor([
'something',
'someething',
'someeething',
'nothing'
], { serviceCollection: serviceCollection }, (editor, cursor) => {
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let selectHighlightsAction = new SelectHighlightsAction();
editor.setSelection(new Selection(1, 1, 1, 1));
findController.getState().change({ searchString: 'some+thing', isRegex: true }, false);
selectHighlightsAction.run(null, editor);
assert.deepEqual(editor.getSelections().map(fromRange), [
[1, 1, 1, 10],
[2, 1, 2, 11],
[3, 1, 3, 12],
]);
assert.equal(findController.getState().searchString, 'some+thing');
findController.dispose();
});
});
test('issue #9043: Clear search scope when find widget is hidden', () => {
withMockCodeEditor([
'var x = (3 * 5)',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册