Skip to content

Commit 79bf64b

Browse files
authored
fix issues with tab move focus mode (microsoft#175135)
1 parent 49dec73 commit 79bf64b

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

src/vs/editor/browser/config/tabFocus.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,20 @@ class TabFocusImpl {
1414
private _tabFocusTerminal: boolean = false;
1515
private _tabFocusEditor: boolean = false;
1616

17-
private readonly _onDidChangeTabFocus = new Emitter<boolean>();
18-
public readonly onDidChangeTabFocus: Event<boolean> = this._onDidChangeTabFocus.event;
17+
private readonly _onDidChangeTabFocus = new Emitter<void>();
18+
public readonly onDidChangeTabFocus: Event<void> = this._onDidChangeTabFocus.event;
1919

2020
public getTabFocusMode(context: TabFocusContext): boolean {
2121
return context === TabFocusContext.Terminal ? this._tabFocusTerminal : this._tabFocusEditor;
2222
}
2323

2424
public setTabFocusMode(tabFocusMode: boolean, context: TabFocusContext): void {
25-
if ((context === TabFocusContext.Terminal && this._tabFocusTerminal === tabFocusMode) || (context === TabFocusContext.Editor && this._tabFocusEditor === tabFocusMode)) {
26-
return;
27-
}
2825
if (context === TabFocusContext.Terminal) {
2926
this._tabFocusTerminal = tabFocusMode;
3027
} else {
3128
this._tabFocusEditor = tabFocusMode;
3229
}
33-
this._onDidChangeTabFocus.fire(this._tabFocusTerminal);
30+
this._onDidChangeTabFocus.fire();
3431
}
3532
}
3633

src/vs/workbench/browser/parts/editor/editorStatus.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
294294
private readonly languageElement = this._register(new MutableDisposable<IStatusbarEntryAccessor>());
295295
private readonly metadataElement = this._register(new MutableDisposable<IStatusbarEntryAccessor>());
296296
private readonly currentProblemStatus: ShowCurrentMarkerInStatusbarContribution = this._register(this.instantiationService.createInstance(ShowCurrentMarkerInStatusbarContribution));
297-
297+
private _previousViewContext: 'terminal' | 'editor' | undefined;
298298
private readonly state = new State();
299299
private readonly activeEditorListeners = this._register(new DisposableStore());
300300
private readonly delayedRender = this._register(new MutableDisposable());
@@ -321,6 +321,19 @@ export class EditorStatus extends Disposable implements IWorkbenchContribution {
321321
this._register(this.textFileService.untitled.onDidChangeEncoding(model => this.onResourceEncodingChange(model.resource)));
322322
this._register(this.textFileService.files.onDidChangeEncoding(model => this.onResourceEncodingChange((model.resource))));
323323
this._register(Event.runAndSubscribe(TabFocus.onDidChangeTabFocus, () => this.onTabFocusModeChange()));
324+
const viewKey = new Set<string>();
325+
viewKey.add('focusedView');
326+
this._register(this.contextKeyService.onDidChangeContext((c) => {
327+
if (c.affectsSome(viewKey)) {
328+
const terminalFocus = this.contextKeyService.getContextKeyValue('focusedView') === 'terminal';
329+
const context = terminalFocus ? 'terminal' : 'editor';
330+
if (this._previousViewContext === context) {
331+
return;
332+
}
333+
this._previousViewContext = context;
334+
this.onTabFocusModeChange();
335+
}
336+
}));
324337
}
325338

326339
private registerCommands(): void {

src/vs/workbench/contrib/terminal/browser/terminalMainContribution.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
77
import { Schemas } from 'vs/base/common/network';
88
import { TabFocus, TabFocusContext } from 'vs/editor/browser/config/tabFocus';
99
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
10-
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
1110
import { ILabelService } from 'vs/platform/label/common/label';
1211
import { TerminalSettingId } from 'vs/platform/terminal/common/terminal';
1312
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
@@ -27,8 +26,7 @@ export class TerminalMainContribution extends Disposable implements IWorkbenchCo
2726
@ITerminalService terminalService: ITerminalService,
2827
@ITerminalEditorService terminalEditorService: ITerminalEditorService,
2928
@ITerminalGroupService terminalGroupService: ITerminalGroupService,
30-
@IConfigurationService configurationService: IConfigurationService,
31-
@IContextKeyService contextKeyService: IContextKeyService
29+
@IConfigurationService configurationService: IConfigurationService
3230
) {
3331
super();
3432

@@ -75,18 +73,7 @@ export class TerminalMainContribution extends Disposable implements IWorkbenchCo
7573
}
7674
});
7775

78-
const viewKey = new Set<string>();
79-
viewKey.add('focusedView');
8076
TabFocus.setTabFocusMode(configurationService.getValue('editor.tabFocusMode'), TabFocusContext.Editor);
8177
TabFocus.setTabFocusMode(configurationService.getValue(TerminalSettingId.TabFocusMode), TabFocusContext.Terminal);
82-
this._register(contextKeyService.onDidChangeContext((c) => {
83-
if (c.affectsSome(viewKey)) {
84-
if (contextKeyService.getContextKeyValue('focusedView') === 'terminal') {
85-
TabFocus.setTabFocusMode(configurationService.getValue(TerminalSettingId.TabFocusMode), TabFocusContext.Terminal);
86-
} else {
87-
TabFocus.setTabFocusMode(configurationService.getValue('editor.tabFocusMode'), TabFocusContext.Editor);
88-
}
89-
}
90-
}));
9178
}
9279
}

0 commit comments

Comments
 (0)