提交 0dda1c30 编写于 作者: S Sandeep Somavarapu

Fix #15116

上级 114160d2
...@@ -46,7 +46,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd ...@@ -46,7 +46,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
private _findWidgetVisible: IContextKey<boolean>; private _findWidgetVisible: IContextKey<boolean>;
protected _state: FindReplaceState; protected _state: FindReplaceState;
private _currentHistoryNavigator: HistoryNavigator<string>; private _currentHistoryNavigator: HistoryNavigator<string>;
private _updateHistoryDelayer: Delayer<void>; protected _updateHistoryDelayer: Delayer<void>;
private _model: FindModelBoundToEditorModel; private _model: FindModelBoundToEditorModel;
public static get(editor: editorCommon.ICommonCodeEditor): CommonFindController { public static get(editor: editorCommon.ICommonCodeEditor): CommonFindController {
......
...@@ -5,11 +5,13 @@ ...@@ -5,11 +5,13 @@
'use strict'; 'use strict';
import * as assert from 'assert'; import * as assert from 'assert';
import { TPromise } from 'vs/base/common/winjs.base';
import { Emitter } from 'vs/base/common/event';
import { EditOperation } from 'vs/editor/common/core/editOperation'; import { EditOperation } from 'vs/editor/common/core/editOperation';
import { Position } from 'vs/editor/common/core/position'; import { Position } from 'vs/editor/common/core/position';
import { Selection } from 'vs/editor/common/core/selection'; import { Selection } from 'vs/editor/common/core/selection';
import { Range } from 'vs/editor/common/core/range'; import { Range } from 'vs/editor/common/core/range';
import { IRange, EndOfLineSequence } from 'vs/editor/common/editorCommon'; import { IRange, EndOfLineSequence, ICommonCodeEditor } from 'vs/editor/common/editorCommon';
import { import {
CommonFindController, FindStartFocusAction, IFindStartOptions, CommonFindController, FindStartFocusAction, IFindStartOptions,
NextMatchFindAction, StartFindAction, SelectHighlightsAction, NextMatchFindAction, StartFindAction, SelectHighlightsAction,
...@@ -17,11 +19,21 @@ import { ...@@ -17,11 +19,21 @@ import {
} from 'vs/editor/contrib/find/common/findController'; } from 'vs/editor/contrib/find/common/findController';
import { MockCodeEditor, withMockCodeEditor } from 'vs/editor/test/common/mocks/mockCodeEditor'; import { MockCodeEditor, withMockCodeEditor } from 'vs/editor/test/common/mocks/mockCodeEditor';
import { HistoryNavigator } from 'vs/base/common/history'; import { HistoryNavigator } from 'vs/base/common/history';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { Delayer } from 'vs/base/common/async';
class TestFindController extends CommonFindController { class TestFindController extends CommonFindController {
public hasFocus: boolean; public hasFocus: boolean;
public delayUpdateHistory: boolean = false; public delayUpdateHistory: boolean = false;
public delayedUpdateHistoryPromise: TPromise<void>;
private _delayedUpdateHistoryEvent: Emitter<void> = new Emitter<void>();
constructor(editor: ICommonCodeEditor, @IContextKeyService contextKeyService: IContextKeyService) {
super(editor, contextKeyService);
this._updateHistoryDelayer = new Delayer<void>(50);
}
protected _start(opts: IFindStartOptions): void { protected _start(opts: IFindStartOptions): void {
super._start(opts); super._start(opts);
...@@ -32,12 +44,26 @@ class TestFindController extends CommonFindController { ...@@ -32,12 +44,26 @@ class TestFindController extends CommonFindController {
} }
protected _delayedUpdateHistory() { protected _delayedUpdateHistory() {
if (!this.delayedUpdateHistoryPromise) {
this.delayedUpdateHistoryPromise = new TPromise<void>((c, e) => {
const disposable = this._delayedUpdateHistoryEvent.event(() => {
disposable.dispose();
this.delayedUpdateHistoryPromise = null;
c(null);
});
});
}
if (this.delayUpdateHistory) { if (this.delayUpdateHistory) {
super._delayedUpdateHistory(); super._delayedUpdateHistory();
} else { } else {
this._updateHistory(); this._updateHistory();
} }
} }
protected _updateHistory() {
super._updateHistory();
this._delayedUpdateHistoryEvent.fire();
}
} }
suite('FindController', () => { suite('FindController', () => {
...@@ -237,10 +263,10 @@ suite('FindController', () => { ...@@ -237,10 +263,10 @@ suite('FindController', () => {
findController.getState().change({ searchString: '2' }, false); findController.getState().change({ searchString: '2' }, false);
findController.getState().change({ searchString: '3' }, false); findController.getState().change({ searchString: '3' }, false);
setTimeout(function () { findController.delayedUpdateHistoryPromise.then(() => {
assert.deepEqual(['3'], toArray(findController.getHistory())); assert.deepEqual(['3'], toArray(findController.getHistory()));
done(); done();
}, 500); });
}); });
}); });
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册