提交 05f3932a 编写于 作者: B Benjamin Pasero

fix #60270

上级 0b4b0dcc
......@@ -8,7 +8,7 @@ import 'vs/css!./media/workbench';
import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { IDisposable, dispose, toDisposable, Disposable } from 'vs/base/common/lifecycle';
import { Event, Emitter } from 'vs/base/common/event';
import { Event, Emitter, once } from 'vs/base/common/event';
import * as DOM from 'vs/base/browser/dom';
import { RunOnceScheduler } from 'vs/base/common/async';
import * as browser from 'vs/base/browser/browser';
......@@ -501,6 +501,10 @@ export class Workbench extends Disposable implements IPartService {
// Fullscreen changes
this._register(browser.onDidChangeFullscreen(() => this.onFullscreenChanged()));
// Group changes
this._register(this.editorGroupService.onDidAddGroup(() => this.centerEditorLayout(this.shouldCenterLayout)));
this._register(this.editorGroupService.onDidRemoveGroup(() => this.centerEditorLayout(this.shouldCenterLayout)));
}
private onFullscreenChanged(): void {
......@@ -658,19 +662,30 @@ export class Workbench extends Disposable implements IPartService {
this.editorPart.whenRestored.then(() => updateEditorContextKeys());
this._register(this.editorService.onDidActiveEditorChange(() => updateEditorContextKeys()));
this._register(this.editorService.onDidVisibleEditorsChange(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidAddGroup(() => {
updateEditorContextKeys();
this.centerEditorLayout(this.shouldCenterLayout);
}));
this._register(this.editorGroupService.onDidRemoveGroup(() => {
updateEditorContextKeys();
this.centerEditorLayout(this.shouldCenterLayout);
}));
this._register(this.editorGroupService.onDidAddGroup(() => updateEditorContextKeys()));
this._register(this.editorGroupService.onDidRemoveGroup(() => updateEditorContextKeys()));
const inputFocused = InputFocusedContext.bindTo(this.contextKeyService);
this._register(DOM.addDisposableListener(window, 'focusin', () => {
inputFocused.set(document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA'));
}, true));
function activeElementIsInput(): boolean {
return document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA');
}
function trackInputFocus(): void {
const isInputFocused = activeElementIsInput();
inputFocused.set(isInputFocused);
if (isInputFocused) {
const tracker = DOM.trackFocus(document.activeElement as HTMLElement);
once(tracker.onDidBlur)(() => {
inputFocused.set(activeElementIsInput());
tracker.dispose();
});
}
}
this._register(DOM.addDisposableListener(window, 'focusin', () => trackInputFocus(), true));
const workbenchStateRawContext = new RawContextKey<string>('workbenchState', getWorkbenchStateString(this.configurationService.getWorkbenchState()));
const workbenchStateContext = workbenchStateRawContext.bindTo(this.contextKeyService);
......
......@@ -20,6 +20,7 @@ import { HideWebViewEditorFindCommand, OpenWebviewDeveloperToolsAction, ReloadWe
import { WebviewEditor } from './webviewEditor';
import { WebviewEditorInput } from './webviewEditorInput';
import { IWebviewEditorService, WebviewEditorService } from './webviewEditorService';
import { InputFocusedContextKey } from 'vs/platform/workbench/common/contextkeys';
(Registry.as<IEditorRegistry>(EditorExtensions.Editors)).registerEditor(new EditorDescriptor(
WebviewEditor,
......@@ -65,7 +66,7 @@ export function registerWebViewCommands(editorId: string): void {
const selectAllCommand = new SelectAllWebviewEditorCommand({
id: SelectAllWebviewEditorCommand.ID,
precondition: contextKeyExpr,
precondition: ContextKeyExpr.and(contextKeyExpr, ContextKeyExpr.not(InputFocusedContextKey)),
kbOpts: {
primary: KeyMod.CtrlCmd | KeyCode.KEY_A,
weight: KeybindingWeight.EditorContrib
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册