Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed #38232 #43950

Merged
merged 3 commits into from
Mar 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/vs/editor/contrib/find/findController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}

public setSearchString(searchString: string): void {
if (this._state.isRegex) {
searchString = strings.escapeRegExpCharacters(searchString);
}
this._state.change({ searchString: searchString }, false);
}

Expand Down Expand Up @@ -538,7 +541,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
if (!this._run(controller)) {
controller.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchStringFromSelection: editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection,
seedSearchStringFromGlobalClipboard: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: true
Expand Down
60 changes: 59 additions & 1 deletion src/vs/editor/contrib/find/test/findController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection';
import { Range } from 'vs/editor/common/core/range';
import * as platform from 'vs/base/common/platform';
import { CommonFindController, FindStartFocusAction, IFindStartOptions, NextMatchFindAction, StartFindAction } from 'vs/editor/contrib/find/findController';
import { CommonFindController, FindStartFocusAction, IFindStartOptions, NextMatchFindAction, StartFindAction, NextSelectionMatchFindAction } from 'vs/editor/contrib/find/findController';
import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor';
import { HistoryNavigator } from 'vs/base/common/history';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
Expand Down Expand Up @@ -475,6 +475,64 @@ suite('FindController', () => {
}
return result;
}

test('issue #38232: Find Next Selection, regex enabled', () => {
withTestCodeEditor([
'([funny]',
'',
'([funny]'
], { serviceCollection: serviceCollection }, (editor, cursor) => {
clipboardState = '';
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();

// toggle regex
findController.getState().change({ isRegex: true }, false);

// change selection
editor.setSelection(new Selection(1, 1, 1, 9));

// cmd+f3
nextSelectionMatchFindAction.run(null, editor);

assert.deepEqual(editor.getSelections().map(fromRange), [
[3, 1, 3, 9]
]);

findController.dispose();
});
});

test('issue #38232: Find Next Selection, regex enabled, find widget open', () => {
withTestCodeEditor([
'([funny]',
'',
'([funny]'
], { serviceCollection: serviceCollection }, (editor, cursor) => {
clipboardState = '';
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
let startFindAction = new StartFindAction();
let nextSelectionMatchFindAction = new NextSelectionMatchFindAction();

// cmd+f - open find widget
startFindAction.run(null, editor);

// toggle regex
findController.getState().change({ isRegex: true }, false);

// change selection
editor.setSelection(new Selection(1, 1, 1, 9));

// cmd+f3
nextSelectionMatchFindAction.run(null, editor);

assert.deepEqual(editor.getSelections().map(fromRange), [
[3, 1, 3, 9]
]);

findController.dispose();
});
});
});

suite('FindController query options persistence', () => {
Expand Down