提交 5dd868c5 编写于 作者: A Alex Dima

Fixes #8404: find in selection activates only through its button

上级 2470fe43
......@@ -71,8 +71,6 @@ export class FindWidget extends Widget implements IOverlayWidget {
private _isVisible: boolean;
private _isReplaceVisible: boolean;
private focusTracker: dom.IFocusTracker;
constructor(
codeEditor: ICodeEditor,
controller: IFindController,
......@@ -95,9 +93,6 @@ export class FindWidget extends Widget implements IOverlayWidget {
this._buildDomNode();
this._updateButtons();
this.focusTracker = this._register(dom.trackFocus(this._findInput.inputBox.inputElement));
this.focusTracker.addFocusListener(() => this._reseedFindScope());
this._register(this._codeEditor.onDidChangeConfiguration((e:IConfigurationChangedEvent) => {
if (e.readOnly) {
if (this._codeEditor.getConfiguration().readOnly) {
......@@ -116,14 +111,6 @@ export class FindWidget extends Widget implements IOverlayWidget {
this._codeEditor.addOverlayWidget(this);
}
private _reseedFindScope(): void {
let selection = this._codeEditor.getSelection();
if (selection.startLineNumber !== selection.endLineNumber) {
// Reseed find scope
this._state.change({ searchScope: selection }, true);
}
}
// ----- IOverlayWidget API
public getId(): string {
......@@ -461,7 +448,10 @@ export class FindWidget extends Widget implements IOverlayWidget {
title: NLS_TOGGLE_SELECTION_FIND_TITLE,
onChange: () => {
if (this._toggleSelectionFind.checked) {
this._reseedFindScope();
let selection = this._codeEditor.getSelection();
if (!selection.isEmpty()) {
this._state.change({ searchScope: selection }, true);
}
} else {
this._state.change({ searchScope: null }, true);
}
......
......@@ -30,7 +30,6 @@ export enum FindStartFocusAction {
export interface IFindStartOptions {
forceRevealReplace:boolean;
seedSearchStringFromSelection:boolean;
seedSearchScopeFromSelection:boolean;
shouldFocus:FindStartFocusAction;
shouldAnimate:boolean;
}
......@@ -65,13 +64,16 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
this.disposeModel();
this._state.change({
searchScope: null
}, false);
if (shouldRestartFind) {
this._start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchScopeFromSelection: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: false
shouldAnimate: false,
});
}
}));
......@@ -170,14 +172,6 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}
}
let selection = this._editor.getSelection();
stateChanges.searchScope = null;
if (opts.seedSearchScopeFromSelection && selection.startLineNumber < selection.endLineNumber) {
// Take search scope into account only if it is more than one line.
stateChanges.searchScope = selection;
}
// Overwrite isReplaceRevealed
if (opts.forceRevealReplace) {
stateChanges.isReplaceRevealed = true;
......@@ -247,7 +241,6 @@ export class StartFindAction extends EditorAction {
controller.start({
forceRevealReplace: false,
seedSearchStringFromSelection: true,
seedSearchScopeFromSelection: true,
shouldFocus: FindStartFocusAction.FocusFindInput,
shouldAnimate: true
});
......@@ -266,7 +259,6 @@ export abstract class MatchFindAction extends EditorAction {
controller.start({
forceRevealReplace: false,
seedSearchStringFromSelection: (controller.getState().searchString.length === 0),
seedSearchScopeFromSelection: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: true
});
......@@ -305,7 +297,6 @@ export abstract class SelectionMatchFindAction extends EditorAction {
controller.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchScopeFromSelection: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: true
});
......@@ -340,7 +331,6 @@ export class StartFindReplaceAction extends EditorAction {
controller.start({
forceRevealReplace: true,
seedSearchStringFromSelection: true,
seedSearchScopeFromSelection: true,
shouldFocus: FindStartFocusAction.FocusReplaceInput,
shouldAnimate: true
});
......
......@@ -32,8 +32,6 @@ export interface INewFindReplaceState {
wholeWord?: boolean;
matchCase?: boolean;
searchScope?: Range;
// matchesPosition?: number;
// matchesCount?: number;
}
export class FindReplaceState implements IDisposable {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册