Skip to content

Commit

Permalink
Fixes #5887: Remove limit for "Change/Select All Occurrences"
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Oct 20, 2017
1 parent c43a3fa commit b8df0a3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/vs/editor/contrib/find/common/findController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IStorageService, StorageScope } from 'vs/platform/storage/common/storag
import { ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations';
import { overviewRulerSelectionHighlightForeground } from 'vs/platform/theme/common/colorRegistry';
import { themeColorFromId } from 'vs/platform/theme/common/themeService';
import { Constants } from 'vs/editor/common/core/uint';

export const enum FindStartFocusAction {
NoFocusChange,
Expand Down Expand Up @@ -801,21 +802,21 @@ export class MoveSelectionToPreviousFindMatchAction extends SelectPreviousFindMa

export abstract class AbstractSelectHighlightsAction extends EditorAction {
public run(accessor: ServicesAccessor, editor: editorCommon.ICommonCodeEditor): void {
let controller = CommonFindController.get(editor);
const controller = CommonFindController.get(editor);
if (!controller) {
return null;
}

let matches: Range[] = null;
let matches: editorCommon.FindMatch[] = null;

const findState = controller.getState();
if (findState.isRevealed && findState.isRegex && findState.searchString.length > 0) {

matches = editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord ? editor.getConfiguration().wordSeparators : null, false).map(m => m.range);
matches = editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord ? editor.getConfiguration().wordSeparators : null, false, Constants.MAX_SAFE_SMALL_INTEGER);

} else {

let r = multiCursorFind(editor, {
const r = multiCursorFind(editor, {
changeFindSearchString: true,
allowMultiline: true,
highlightFindOptions: true
Expand All @@ -824,22 +825,22 @@ export abstract class AbstractSelectHighlightsAction extends EditorAction {
return;
}

matches = editor.getModel().findMatches(r.searchText, true, false, r.matchCase, r.wholeWord ? editor.getConfiguration().wordSeparators : null, false).map(m => m.range);
matches = editor.getModel().findMatches(r.searchText, true, false, r.matchCase, r.wholeWord ? editor.getConfiguration().wordSeparators : null, false, Constants.MAX_SAFE_SMALL_INTEGER);
}

if (matches.length > 0) {
let editorSelection = editor.getSelection();
const editorSelection = editor.getSelection();
for (let i = 0, len = matches.length; i < len; i++) {
let match = matches[i];
let intersection = match.intersectRanges(editorSelection);
const match = matches[i];
let intersection = match.range.intersectRanges(editorSelection);
if (intersection) {
// bingo!
matches.splice(i, 1);
matches.unshift(match);
break;
}
}
editor.setSelections(matches.map(m => new Selection(m.startLineNumber, m.startColumn, m.endLineNumber, m.endColumn)));
editor.setSelections(matches.map(m => new Selection(m.range.startLineNumber, m.range.startColumn, m.range.endLineNumber, m.range.endColumn)));
}
}
}
Expand Down

0 comments on commit b8df0a3

Please sign in to comment.