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

Fixes #9043: Clear search scope when find widget is hidden

上级 6961b52e
......@@ -111,7 +111,10 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}
public closeFindWidget(): void {
this._state.change({ isRevealed: false }, false);
this._state.change({
isRevealed: false,
searchScope: null
}, false);
this._editor.focus();
}
......
......@@ -48,11 +48,13 @@ export class FindModelBoundToEditorModel {
private _ignoreModelContentChanged:boolean;
private _updateDecorationsScheduler:RunOnceScheduler;
private _isDisposed: boolean;
constructor(editor:editorCommon.ICommonCodeEditor, state:FindReplaceState) {
this._editor = editor;
this._state = state;
this._toDispose = [];
this._isDisposed = false;
this._decorations = new FindDecorations(editor);
this._toDispose.push(this._decorations);
......@@ -89,10 +91,15 @@ export class FindModelBoundToEditorModel {
}
public dispose(): void {
this._isDisposed = true;
this._toDispose = dispose(this._toDispose);
}
private _onStateChanged(e:FindReplaceStateChangedEvent): void {
if (this._isDisposed) {
// The find model is disposed during a find state changed event
return;
}
if (e.searchString || e.isReplaceRevealed || e.isRegex || e.wholeWord || e.matchCase || e.searchScope) {
if (e.searchScope) {
this.research(e.moveCursor, this._state.searchScope);
......
......@@ -174,4 +174,32 @@ suite('FindController', () => {
selectHighlightsAction.dispose();
});
});
test('issue #9043: Clear search scope when find widget is hidden', () => {
withMockCodeEditor([
'var x = (3 * 5)',
'var y = (3 * 5)',
'var z = (3 * 5)',
], {}, (editor, cursor) => {
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
findController.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: false
});
assert.equal(findController.getState().searchScope, null);
findController.getState().change({
searchScope: new Range(1, 1, 1, 5)
}, false);
assert.deepEqual(findController.getState().searchScope, new Range(1, 1, 1, 5));
findController.closeFindWidget();
assert.equal(findController.getState().searchScope, null);
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册