提交 5d45460c 编写于 作者: M Matt Bierner

Reducing cycles

上级 526335be
......@@ -4,52 +4,50 @@
*--------------------------------------------------------------------------------------------*/
import { SimpleFindWidget } from 'vs/editor/contrib/find/simpleFindWidget';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { Webview } from 'vs/workbench/contrib/webview/common/webview';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
export interface WebviewFindDelegate {
find(value: string, previous: boolean): void;
startFind(value: string): void;
stopFind(keepSelection?: boolean): void;
focus(): void;
}
export class WebviewFindWidget extends SimpleFindWidget {
constructor(
private _webview: Webview | undefined,
private readonly _delegate: WebviewFindDelegate,
@IContextViewService contextViewService: IContextViewService,
@IContextKeyService contextKeyService: IContextKeyService
) {
super(contextViewService, contextKeyService);
}
dispose() {
this._webview = undefined;
super.dispose();
}
public find(previous: boolean) {
if (!this._webview) {
return;
}
const val = this.inputValue;
if (val) {
this._webview.find(val, previous);
this._delegate.find(val, previous);
}
}
public hide() {
super.hide();
if (this._webview) {
this._webview.stopFind(true);
this._webview.focus();
if (this._delegate) {
this._delegate.stopFind(true);
this._delegate.focus();
}
}
public onInputChanged() {
if (!this._webview) {
if (!this._delegate) {
return;
}
const val = this.inputValue;
if (val) {
this._webview.startFind(val);
this._delegate.startFind(val);
} else {
this._webview.stopFind(false);
this._delegate.stopFind(false);
}
}
......
......@@ -16,6 +16,9 @@ export const KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE = new RawContextKey<
export const IWebviewService = createDecorator<IWebviewService>('webviewService');
/**
* Handles the creation of webview elements.
*/
export interface IWebviewService {
_serviceBrand: any;
......@@ -82,7 +85,4 @@ export interface Webview {
showFind(): void;
hideFind(): void;
find(value: string, previous: boolean): void;
startFind(value: string): void;
stopFind(keepSelection?: boolean): void;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册