提交 dc62a6ef 编写于 作者: S Sandeep Somavarapu

Fix #17577

上级 23efb2fb
......@@ -32,13 +32,26 @@ export abstract class Composite extends Component implements IComposite {
private _onDidFocus: Emitter<void>;
get onDidFocus(): Event<void> {
if (!this._onDidFocus) {
this._onDidFocus = this._register(new Emitter<void>());
this._registerFocusTrackEvents();
}
return this._onDidFocus.event;
}
const focusTracker = this._register(trackFocus(this.getContainer()));
this._register(focusTracker.onDidFocus(() => this._onDidFocus.fire()));
private _onDidBlur: Emitter<void>;
get onDidBlur(): Event<void> {
if (!this._onDidBlur) {
this._registerFocusTrackEvents();
}
return this._onDidBlur.event;
}
return this._onDidFocus.event;
private _registerFocusTrackEvents(): void {
this._onDidFocus = this._register(new Emitter<void>());
this._onDidBlur = this._register(new Emitter<void>());
const focusTracker = this._register(trackFocus(this.getContainer()));
this._register(focusTracker.onDidFocus(() => this._onDidFocus.fire()));
this._register(focusTracker.onDidBlur(() => this._onDidBlur.fire()));
}
protected actionRunner: IActionRunner;
......
......@@ -77,6 +77,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
private viewModel: SearchModel;
private viewletVisible: IContextKey<boolean>;
private viewletFocused: IContextKey<boolean>;
private inputBoxFocused: IContextKey<boolean>;
private inputPatternIncludesFocused: IContextKey<boolean>;
private inputPatternExclusionsFocused: IContextKey<boolean>;
......@@ -139,6 +140,7 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
super(VIEW_ID, partService, telemetryService, themeService);
this.viewletVisible = Constants.SearchViewVisibleKey.bindTo(contextKeyService);
this.viewletFocused = Constants.SearchViewFocusedKey.bindTo(contextKeyService);
this.inputBoxFocused = Constants.InputBoxFocusedKey.bindTo(this.contextKeyService);
this.inputPatternIncludesFocused = Constants.PatternIncludesFocusedKey.bindTo(this.contextKeyService);
this.inputPatternExclusionsFocused = Constants.PatternExcludesFocusedKey.bindTo(this.contextKeyService);
......@@ -273,6 +275,9 @@ export class SearchView extends Viewlet implements IViewlet, IPanel {
this._register(this.viewModel.searchResult.onChange((event) => this.onSearchResultsChanged(event)));
this._register(this.onDidFocus(() => this.viewletFocused.set(true)));
this._register(this.onDidBlur(() => this.viewletFocused.set(false)));
return TPromise.as(null);
}
......
......@@ -28,6 +28,7 @@ export const ToggleRegexCommandId = 'toggleSearchRegex';
export const ToggleSearchViewPositionCommandId = 'search.action.toggleSearchViewPosition';
export const SearchViewVisibleKey = new RawContextKey<boolean>('searchViewletVisible', true);
export const SearchViewFocusedKey = new RawContextKey<boolean>('searchViewletFocus', false);
export const InputBoxFocusedKey = new RawContextKey<boolean>('inputBoxFocus', false);
export const SearchInputBoxFocusedKey = new RawContextKey<boolean>('searchInputBoxFocus', false);
export const ReplaceInputBoxFocusedKey = new RawContextKey<boolean>('replaceInputBoxFocus', false);
......
......@@ -501,21 +501,21 @@ MenuRegistry.appendMenuItem(MenuId.MenubarEditMenu, {
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: Constants.ToggleCaseSensitiveCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey),
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchViewFocusedKey, Constants.FileMatchOrFolderMatchFocusKey.toNegated()),
handler: toggleCaseSensitiveCommand
}, ToggleCaseSensitiveKeybinding));
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: Constants.ToggleWholeWordCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey),
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchViewFocusedKey),
handler: toggleWholeWordCommand
}, ToggleWholeWordKeybinding));
KeybindingsRegistry.registerCommandAndKeybindingRule(objects.assign({
id: Constants.ToggleRegexCommandId,
weight: KeybindingWeight.WorkbenchContrib,
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchInputBoxFocusedKey),
when: ContextKeyExpr.and(Constants.SearchViewVisibleKey, Constants.SearchViewFocusedKey),
handler: toggleRegexCommand
}, ToggleRegexKeybinding));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册