mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-27 03:54:24 +01:00
Unable to next/previous via keybindings when diff editor is not focused (fixes #14124)
This commit is contained in:
@@ -8,11 +8,11 @@ import * as types from 'vs/base/common/types';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
import { ActiveEditorMoveArguments, ActiveEditorMovePositioning, ActiveEditorMovePositioningBy, EditorCommands } from 'vs/workbench/common/editor';
|
||||
import { ActiveEditorMoveArguments, ActiveEditorMovePositioning, ActiveEditorMovePositioningBy, EditorCommands, TextCompareEditorVisible } from 'vs/workbench/common/editor';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditor, Position, POSITIONS } from 'vs/platform/editor/common/editor';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorCommon';
|
||||
import { TextCompareEditorVisible, TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
|
||||
import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
|
||||
import { EditorStacksModel } from 'vs/workbench/common/editor/editorStacksModel';
|
||||
import { ICommandService } from 'vs/platform/commands/common/commands';
|
||||
import { IMessageService, Severity, CloseAction } from 'vs/platform/message/common/message';
|
||||
|
||||
@@ -21,7 +21,7 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import { Scope as MementoScope } from 'vs/workbench/common/memento';
|
||||
import { Part } from 'vs/workbench/browser/part';
|
||||
import { BaseEditor, EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions, EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, IEditorDescriptor, TextEditorOptions, SideBySideEditorInput } from 'vs/workbench/common/editor';
|
||||
import { IEditorRegistry, Extensions as EditorExtensions, EditorInput, EditorOptions, ConfirmResult, IWorkbenchEditorConfiguration, IEditorDescriptor, TextEditorOptions, SideBySideEditorInput, TextCompareEditorVisible, TEXT_DIFF_EDITOR_ID } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupsControl, Rochade, IEditorGroupsControl, ProgressState } from 'vs/workbench/browser/parts/editor/editorGroupsControl';
|
||||
import { WorkbenchProgressService } from 'vs/workbench/services/progress/browser/progressService';
|
||||
import { IEditorGroupService, GroupOrientation, GroupArrangement, ITabOptions } from 'vs/workbench/services/group/common/groupService';
|
||||
@@ -37,6 +37,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IProgressService } from 'vs/platform/progress/common/progress';
|
||||
import { EditorStacksModel, EditorGroup, EditorIdentifier, GroupEvent } from 'vs/workbench/common/editor/editorStacksModel';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
class ProgressMonitor {
|
||||
|
||||
@@ -93,6 +94,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
private _onGroupOrientationChanged: Emitter<void>;
|
||||
private _onTabOptionsChanged: Emitter<ITabOptions>;
|
||||
|
||||
private textCompareEditorVisible: IContextKey<boolean>;
|
||||
|
||||
// The following data structures are partitioned into array of Position as provided by Services.POSITION array
|
||||
private visibleEditors: BaseEditor[];
|
||||
private instantiatedEditors: BaseEditor[][];
|
||||
@@ -109,6 +112,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
@IStorageService private storageService: IStorageService,
|
||||
@IPartService private partService: IPartService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService
|
||||
) {
|
||||
super(id);
|
||||
@@ -132,6 +136,8 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
|
||||
this.stacks = this.instantiationService.createInstance(EditorStacksModel, restoreFromStorage);
|
||||
|
||||
this.textCompareEditorVisible = TextCompareEditorVisible.bindTo(contextKeyService);
|
||||
|
||||
const config = configurationService.getConfiguration<IWorkbenchEditorConfiguration>();
|
||||
if (config && config.workbench && config.workbench.editor) {
|
||||
const editorConfig = config.workbench.editor;
|
||||
@@ -350,6 +356,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
// Indicate to editor that it is now visible
|
||||
editor.setVisible(true, position);
|
||||
|
||||
// Update text compare editor visible context
|
||||
this.updateTextCompareEditorVisible();
|
||||
|
||||
// Make sure the editor is layed out
|
||||
this.editorGroupsControl.layout(position);
|
||||
|
||||
@@ -595,6 +604,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
editor.clearInput();
|
||||
editor.setVisible(false);
|
||||
|
||||
// Update text compare editor visible context
|
||||
this.updateTextCompareEditorVisible();
|
||||
|
||||
// Clear active editor
|
||||
this.visibleEditors[position] = null;
|
||||
|
||||
@@ -607,6 +619,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
|
||||
}
|
||||
}
|
||||
|
||||
private updateTextCompareEditorVisible(): void {
|
||||
this.textCompareEditorVisible.set(this.visibleEditors.some(e => e && e.isVisible() && e.getId() === TEXT_DIFF_EDITOR_ID));
|
||||
}
|
||||
|
||||
public closeAllEditors(except?: Position): TPromise<void> {
|
||||
let groups = this.stacks.groups.reverse(); // start from the end to prevent layout to happen through rochade
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import { Builder } from 'vs/base/browser/builder';
|
||||
import { Action, IAction } from 'vs/base/common/actions';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import types = require('vs/base/common/types');
|
||||
import { Position } from 'vs/platform/editor/common/editor';
|
||||
import { IDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/editorCommon';
|
||||
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
@@ -31,13 +30,10 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
|
||||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { RawContextKey, IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IThemeService } from 'vs/workbench/services/themes/common/themeService';
|
||||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
|
||||
|
||||
export const TextCompareEditorVisible = new RawContextKey<boolean>('textCompareEditorVisible', false);
|
||||
|
||||
/**
|
||||
* The text editor that leverages the diff text editor for the editing experience.
|
||||
*/
|
||||
@@ -49,22 +45,17 @@ export class TextDiffEditor extends BaseTextEditor {
|
||||
private nextDiffAction: NavigateAction;
|
||||
private previousDiffAction: NavigateAction;
|
||||
|
||||
private textDiffEditorVisible: IContextKey<boolean>;
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IStorageService storageService: IStorageService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IEditorGroupService private editorGroupService: IEditorGroupService,
|
||||
@ITextFileService textFileService: ITextFileService
|
||||
) {
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService);
|
||||
|
||||
this.textDiffEditorVisible = TextCompareEditorVisible.bindTo(contextKeyService);
|
||||
}
|
||||
|
||||
public getTitle(): string {
|
||||
@@ -263,12 +254,6 @@ export class TextDiffEditor extends BaseTextEditor {
|
||||
super.clearInput();
|
||||
}
|
||||
|
||||
public setEditorVisible(visible: boolean, position: Position): void {
|
||||
this.textDiffEditorVisible.set(visible);
|
||||
|
||||
super.setEditorVisible(visible, position);
|
||||
}
|
||||
|
||||
public getDiffNavigator(): DiffNavigator {
|
||||
return this.diffNavigator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user