editors - fix cyclic dependency
This commit is contained in:
parent
7667e90bf8
commit
75aa22e7d9
|
@ -23,7 +23,8 @@ import { IUndoRedoService, UndoRedoElementType } from 'vs/platform/undoRedo/comm
|
|||
import { MainThreadWebviewPanels } from 'vs/workbench/api/browser/mainThreadWebviewPanels';
|
||||
import { MainThreadWebviews, reviveWebviewExtension } from 'vs/workbench/api/browser/mainThreadWebviews';
|
||||
import * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { editorGroupToViewColumn, IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
|
||||
import { IRevertOptions, ISaveOptions } from 'vs/workbench/common/editor';
|
||||
import { editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { CustomEditorInput } from 'vs/workbench/contrib/customEditor/browser/customEditorInput';
|
||||
import { CustomDocumentBackupData } from 'vs/workbench/contrib/customEditor/browser/customEditorInputFactory';
|
||||
import { ICustomEditorModel, ICustomEditorService } from 'vs/workbench/contrib/customEditor/common/customEditor';
|
||||
|
@ -195,7 +196,7 @@ export class MainThreadCustomEditors extends Disposable implements extHostProtoc
|
|||
title: webviewInput.getTitle(),
|
||||
webviewOptions: webviewInput.webview.contentOptions,
|
||||
panelOptions: webviewInput.webview.options,
|
||||
}, editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0), cancellation);
|
||||
}, editorGroupToColumn(this._editorGroupService, webviewInput.group || 0), cancellation);
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
webviewInput.webview.html = this.mainThreadWebview.getWebviewResolvedFailedContent(viewType);
|
||||
|
|
|
@ -20,7 +20,8 @@ import { MainThreadTextEditor } from 'vs/workbench/api/browser/mainThreadEditor'
|
|||
import { MainThreadTextEditors } from 'vs/workbench/api/browser/mainThreadEditors';
|
||||
import { ExtHostContext, ExtHostDocumentsAndEditorsShape, IDocumentsAndEditorsDelta, IExtHostContext, IModelAddedData, ITextEditorAddData, MainContext } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
|
||||
import { editorGroupToViewColumn, EditorGroupColumn, IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { IEditorPane } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn, editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
|
||||
|
@ -412,7 +413,7 @@ export class MainThreadDocumentsAndEditors {
|
|||
private _findEditorPosition(editor: MainThreadTextEditor): EditorGroupColumn | undefined {
|
||||
for (const editorPane of this._editorService.visibleEditorPanes) {
|
||||
if (editor.matches(editorPane)) {
|
||||
return editorGroupToViewColumn(this._editorGroupService, editorPane.group);
|
||||
return editorGroupToColumn(this._editorGroupService, editorPane.group);
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
|
|
|
@ -19,7 +19,7 @@ import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation
|
|||
import { MainThreadDocumentsAndEditors } from 'vs/workbench/api/browser/mainThreadDocumentsAndEditors';
|
||||
import { MainThreadTextEditor } from 'vs/workbench/api/browser/mainThreadEditor';
|
||||
import { ExtHostContext, ExtHostEditorsShape, IApplyEditsOptions, IExtHostContext, ITextDocumentShowOptions, ITextEditorConfigurationUpdate, ITextEditorPositionData, IUndoStopOptions, MainThreadTextEditorsShape, TextEditorRevealType, IWorkspaceEditDto, WorkspaceEditType } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { editorGroupToViewColumn, EditorGroupColumn, viewColumnToEditorGroup } from 'vs/workbench/common/editor';
|
||||
import { editorGroupToColumn, columnToEditorGroup, EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
@ -126,7 +126,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
|
|||
for (let editorPane of this._editorService.visibleEditorPanes) {
|
||||
const id = this._documentsAndEditors.findTextEditorIdFor(editorPane);
|
||||
if (id) {
|
||||
result[id] = editorGroupToViewColumn(this._editorGroupService, editorPane.group);
|
||||
result[id] = editorGroupToColumn(this._editorGroupService, editorPane.group);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -152,7 +152,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
|
|||
options: editorOptions
|
||||
};
|
||||
|
||||
const editor = await this._editorService.openEditor(input, viewColumnToEditorGroup(this._editorGroupService, options.position));
|
||||
const editor = await this._editorService.openEditor(input, columnToEditorGroup(this._editorGroupService, options.position));
|
||||
if (!editor) {
|
||||
return undefined;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ export class MainThreadTextEditors implements MainThreadTextEditorsShape {
|
|||
await this._editorService.openEditor({
|
||||
resource: model.uri,
|
||||
options: { preserveFocus: false }
|
||||
}, viewColumnToEditorGroup(this._editorGroupService, position));
|
||||
}, columnToEditorGroup(this._editorGroupService, position));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import { MainThreadNotebookDocuments } from 'vs/workbench/api/browser/mainThread
|
|||
import { NotebookDto } from 'vs/workbench/api/browser/mainThreadNotebookDto';
|
||||
import { MainThreadNotebookEditors } from 'vs/workbench/api/browser/mainThreadNotebookEditors';
|
||||
import { extHostCustomer } from 'vs/workbench/api/common/extHostCustomers';
|
||||
import { editorGroupToViewColumn } from 'vs/workbench/common/editor';
|
||||
import { editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { getNotebookEditorFromEditorPane, IActiveNotebookEditor, INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser';
|
||||
import { INotebookEditorService } from 'vs/workbench/contrib/notebook/browser/notebookEditorService';
|
||||
import { NotebookTextModel } from 'vs/workbench/contrib/notebook/common/model/notebookTextModel';
|
||||
|
@ -240,7 +240,7 @@ export class MainThreadNotebooksAndEditors {
|
|||
documentUri: add.textModel.uri,
|
||||
selections: add.getSelections(),
|
||||
visibleRanges: add.visibleRanges,
|
||||
viewColumn: pane && editorGroupToViewColumn(this._editorGroupService, pane.group)
|
||||
viewColumn: pane && editorGroupToColumn(this._editorGroupService, pane.group)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ import { NotebookEditorInput } from 'vs/workbench/contrib/notebook/common/notebo
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { editorGroupToViewColumn } from 'vs/workbench/common/editor';
|
||||
import { editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
import { NotebookDto } from 'vs/workbench/api/browser/mainThreadNotebookDto';
|
||||
|
||||
|
@ -96,7 +96,7 @@ export class MainThreadNotebookEditors implements MainThreadNotebookEditorsShape
|
|||
for (let editorPane of this._editorService.visibleEditorPanes) {
|
||||
const candidate = getNotebookEditorFromEditorPane(editorPane);
|
||||
if (candidate && this._mainThreadEditors.has(candidate.getId())) {
|
||||
result[candidate.getId()] = editorGroupToViewColumn(this._editorGroupService, editorPane.group);
|
||||
result[candidate.getId()] = editorGroupToColumn(this._editorGroupService, editorPane.group);
|
||||
}
|
||||
}
|
||||
if (!equals(result, this._currentViewColumnInfo)) {
|
||||
|
|
|
@ -9,7 +9,8 @@ import { URI, UriComponents } from 'vs/base/common/uri';
|
|||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { MainThreadWebviews, reviveWebviewContentOptions, reviveWebviewExtension } from 'vs/workbench/api/browser/mainThreadWebviews';
|
||||
import * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { EditorGroupColumn, editorGroupToViewColumn, IEditorInput, viewColumnToEditorGroup } from 'vs/workbench/common/editor';
|
||||
import { IEditorInput } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn, columnToEditorGroup, editorGroupToColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
|
||||
import { WebviewOptions } from 'vs/workbench/contrib/webview/browser/webview';
|
||||
import { WebviewInput } from 'vs/workbench/contrib/webviewPanel/browser/webviewEditorInput';
|
||||
|
@ -161,7 +162,7 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc
|
|||
const mainThreadShowOptions: ICreateWebViewShowOptions = Object.create(null);
|
||||
if (showOptions) {
|
||||
mainThreadShowOptions.preserveFocus = !!showOptions.preserveFocus;
|
||||
mainThreadShowOptions.group = viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn);
|
||||
mainThreadShowOptions.group = columnToEditorGroup(this._editorGroupService, showOptions.viewColumn);
|
||||
}
|
||||
|
||||
const extension = reviveWebviewExtension(extensionData);
|
||||
|
@ -202,7 +203,7 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc
|
|||
return;
|
||||
}
|
||||
|
||||
const targetGroup = this._editorGroupService.getGroup(viewColumnToEditorGroup(this._editorGroupService, showOptions.viewColumn)) || this._editorGroupService.getGroup(webview.group || 0);
|
||||
const targetGroup = this._editorGroupService.getGroup(columnToEditorGroup(this._editorGroupService, showOptions.viewColumn)) || this._editorGroupService.getGroup(webview.group || 0);
|
||||
if (targetGroup) {
|
||||
this._webviewWorkbenchService.revealWebview(webview, targetGroup, !!showOptions.preserveFocus);
|
||||
}
|
||||
|
@ -243,7 +244,7 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc
|
|||
state,
|
||||
panelOptions: webviewInput.webview.options,
|
||||
webviewOptions: webviewInput.webview.contentOptions,
|
||||
}, editorGroupToViewColumn(this._editorGroupService, webviewInput.group || 0));
|
||||
}, editorGroupToColumn(this._editorGroupService, webviewInput.group || 0));
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
webviewInput.webview.html = this._mainThreadWebviews.getWebviewResolvedFailedContent(viewType);
|
||||
|
@ -281,7 +282,7 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc
|
|||
viewStates[handle] = {
|
||||
visible: topLevelInput === group.activeEditor,
|
||||
active: editorInput === activeEditorInput,
|
||||
position: editorGroupToViewColumn(this._editorGroupService, group.id),
|
||||
position: editorGroupToColumn(this._editorGroupService, group.id),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ import { ExtHostInteractive } from 'vs/workbench/api/common/extHostInteractive';
|
|||
import { TunnelDto } from 'vs/workbench/api/common/extHostTunnelService';
|
||||
import { DebugConfigurationProviderTriggerKind, TestResultState } from 'vs/workbench/api/common/extHostTypes';
|
||||
import * as tasks from 'vs/workbench/api/common/shared/tasks';
|
||||
import { EditorGroupColumn, SaveReason } from 'vs/workbench/common/editor';
|
||||
import { SaveReason } from 'vs/workbench/common/editor';
|
||||
import { IRevealOptions, ITreeItem } from 'vs/workbench/common/views';
|
||||
import { CallHierarchyItem } from 'vs/workbench/contrib/callHierarchy/common/callHierarchy';
|
||||
import { IAdapterDescriptor, IConfig, IDebugSessionReplMode } from 'vs/workbench/contrib/debug/common/debug';
|
||||
|
@ -59,6 +59,7 @@ import { ITextQueryBuilderOptions } from 'vs/workbench/contrib/search/common/que
|
|||
import { ISerializableEnvironmentVariableCollection } from 'vs/workbench/contrib/terminal/common/environmentVariable';
|
||||
import { ExtensionRunTestsRequest, ISerializedTestResults, ITestItem, ITestMessage, ITestRunTask, RunTestForControllerRequest, RunTestsRequest, ITestIdWithSrc, TestsDiff, IFileCoverage, CoverageDetails } from 'vs/workbench/contrib/testing/common/testCollection';
|
||||
import { InternalTimelineOptions, Timeline, TimelineChangeEvent, TimelineOptions, TimelineProviderDescriptor } from 'vs/workbench/contrib/timeline/common/timeline';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { ActivationKind, ExtensionHostKind, MissingExtensionDependency } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { createExtHostContextProxyIdentifier as createExtId, createMainContextProxyIdentifier as createMainId, IRPCProtocol } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { CandidatePort } from 'vs/workbench/services/remote/common/remoteExplorerService';
|
||||
|
|
|
@ -16,7 +16,7 @@ import { IExtensionStoragePaths } from 'vs/workbench/api/common/extHostStoragePa
|
|||
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { ExtHostWebviews, shouldSerializeBuffersForPostMessage, toExtensionData } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { ExtHostWebviewPanels } from 'vs/workbench/api/common/extHostWebviewPanels';
|
||||
import { EditorGroupColumn } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import type * as vscode from 'vscode';
|
||||
import { Cache } from './cache';
|
||||
import * as extHostProtocol from './extHost.protocol';
|
||||
|
|
|
@ -26,11 +26,12 @@ import * as extHostProtocol from 'vs/workbench/api/common/extHost.protocol';
|
|||
import { CommandsConverter } from 'vs/workbench/api/common/extHostCommands';
|
||||
import { ExtHostDocumentsAndEditors } from 'vs/workbench/api/common/extHostDocumentsAndEditors';
|
||||
import { ExtHostNotebookController } from 'vs/workbench/api/common/extHostNotebook';
|
||||
import { EditorGroupColumn, SaveReason } from 'vs/workbench/common/editor';
|
||||
import { SaveReason } from 'vs/workbench/common/editor';
|
||||
import * as notebooks from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { ICellRange } from 'vs/workbench/contrib/notebook/common/notebookRange';
|
||||
import * as search from 'vs/workbench/contrib/search/common/search';
|
||||
import { CoverageDetails, DetailType, ICoveredCount, IFileCoverage, ISerializedTestResults, ITestItem, ITestItemContext, ITestMessage, SerializedTestResultItem } from 'vs/workbench/contrib/testing/common/testCollection';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import type * as vscode from 'vscode';
|
||||
import * as types from './extHostTypes';
|
||||
|
|
|
@ -11,7 +11,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
|
|||
import * as typeConverters from 'vs/workbench/api/common/extHostTypeConverters';
|
||||
import { serializeWebviewOptions, ExtHostWebview, ExtHostWebviews, toExtensionData, shouldSerializeBuffersForPostMessage } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { IExtHostWorkspace } from 'vs/workbench/api/common/extHostWorkspace';
|
||||
import { EditorGroupColumn } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import type * as vscode from 'vscode';
|
||||
import * as extHostProtocol from './extHost.protocol';
|
||||
import * as extHostTypes from './extHostTypes';
|
||||
|
|
|
@ -7,7 +7,8 @@ import { localize } from 'vs/nls';
|
|||
import { isObject, isString, isUndefined, isNumber, withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { KeybindingsRegistry, KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
|
||||
import { TextCompareEditorVisibleContext, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditorInput, IVisibleEditorPane, ActiveEditorStickyContext, EditorsOrder, viewColumnToEditorGroup, EditorGroupColumn, EditorInputCapabilities, isEditorIdentifier } from 'vs/workbench/common/editor';
|
||||
import { TextCompareEditorVisibleContext, IEditorIdentifier, IEditorCommandsContext, ActiveEditorGroupEmptyContext, MultipleEditorGroupsContext, CloseDirection, IEditorInput, IVisibleEditorPane, ActiveEditorStickyContext, EditorsOrder, EditorInputCapabilities, isEditorIdentifier } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn, columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
|
||||
|
@ -451,7 +452,7 @@ function registerOpenEditorAPICommands(): void {
|
|||
if (optionsArg || typeof columnArg === 'number') {
|
||||
const [options, column] = mixinContext(context, optionsArg, columnArg);
|
||||
|
||||
await editorService.openEditor({ resource, options, label }, viewColumnToEditorGroup(editorGroupService, column));
|
||||
await editorService.openEditor({ resource, options, label }, columnToEditorGroup(editorGroupService, column));
|
||||
}
|
||||
|
||||
// do not allow to execute commands from here
|
||||
|
@ -495,7 +496,7 @@ function registerOpenEditorAPICommands(): void {
|
|||
modified: { resource: URI.revive(modifiedResource) },
|
||||
label,
|
||||
options
|
||||
}, viewColumnToEditorGroup(editorGroupService, column));
|
||||
}, columnToEditorGroup(editorGroupService, column));
|
||||
});
|
||||
|
||||
CommandsRegistry.registerCommand(API_OPEN_WITH_EDITOR_COMMAND_ID, (accessor: ServicesAccessor, resource: UriComponents, id: string, columnAndOptions?: [EditorGroupColumn?, ITextEditorOptions?]) => {
|
||||
|
@ -515,7 +516,7 @@ function registerOpenEditorAPICommands(): void {
|
|||
}
|
||||
group = neighbourGroup;
|
||||
} else {
|
||||
group = editorGroupsService.getGroup(viewColumnToEditorGroup(editorGroupsService, columnArg)) ?? editorGroupsService.activeGroup;
|
||||
group = editorGroupsService.getGroup(columnToEditorGroup(editorGroupsService, columnArg)) ?? editorGroupsService.activeGroup;
|
||||
}
|
||||
|
||||
return editorService.openEditor({ resource: URI.revive(resource), options: { ...optionsArg, pinned: true, override: id } }, group);
|
||||
|
|
|
@ -14,12 +14,11 @@ import { IInstantiationService, IConstructorSignature0, ServicesAccessor, Brande
|
|||
import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { IEncodingSupport, IModeSupport } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { GroupsOrder, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ICompositeControl, IComposite } from 'vs/workbench/common/composite';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IPathData } from 'vs/platform/windows/common/windows';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IExtUri } from 'vs/base/common/resources';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
|
||||
|
@ -1154,37 +1153,3 @@ export const enum EditorsOrder {
|
|||
*/
|
||||
SEQUENTIAL
|
||||
}
|
||||
|
||||
/**
|
||||
* A way to address editor groups through a column based system
|
||||
* where `0` is the first column. Will fallback to `SIDE_GROUP`
|
||||
* in case the column does not exist yet.
|
||||
*/
|
||||
export type EditorGroupColumn = number;
|
||||
|
||||
export function viewColumnToEditorGroup(editorGroupService: IEditorGroupsService, viewColumn?: EditorGroupColumn): GroupIdentifier {
|
||||
if (typeof viewColumn !== 'number' || viewColumn === ACTIVE_GROUP) {
|
||||
return ACTIVE_GROUP; // prefer active group when position is undefined or passed in as such
|
||||
}
|
||||
|
||||
const groups = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE);
|
||||
|
||||
let candidateGroup = groups[viewColumn];
|
||||
if (candidateGroup) {
|
||||
return candidateGroup.id; // found direct match
|
||||
}
|
||||
|
||||
let firstGroup = groups[0];
|
||||
if (groups.length === 1 && firstGroup.count === 0) {
|
||||
return firstGroup.id; // first editor should always open in first group independent from position provided
|
||||
}
|
||||
|
||||
return SIDE_GROUP; // open to the side if group not found or we are instructed to
|
||||
}
|
||||
|
||||
export function editorGroupToViewColumn(editorGroupService: IEditorGroupsService, editorGroup: IEditorGroup | GroupIdentifier): EditorGroupColumn {
|
||||
let group = (typeof editorGroup === 'number') ? editorGroupService.getGroup(editorGroup) : editorGroup;
|
||||
group = group ?? editorGroupService.activeGroup;
|
||||
|
||||
return editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE).indexOf(group);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,8 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||
import { EditorPaneDescriptor, IEditorPaneRegistry } from 'vs/workbench/browser/editor';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { EditorInput } from 'vs/workbench/common/editor/editorInput';
|
||||
import { EditorExtensions, EditorsOrder, IEditorInputSerializer, viewColumnToEditorGroup } from 'vs/workbench/common/editor';
|
||||
import { EditorExtensions, EditorsOrder, IEditorInputSerializer } from 'vs/workbench/common/editor';
|
||||
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { InteractiveEditor } from 'vs/workbench/contrib/interactive/browser/interactiveEditor';
|
||||
import { InteractiveEditorInput } from 'vs/workbench/contrib/interactive/browser/interactiveEditorInput';
|
||||
import { NOTEBOOK_EDITOR_WIDGET_ACTION_WEIGHT } from 'vs/workbench/contrib/notebook/browser/contrib/coreActions';
|
||||
|
@ -288,7 +289,7 @@ registerAction2(class extends Action2 {
|
|||
const editorGroupService = accessor.get(IEditorGroupsService);
|
||||
const historyService = accessor.get(IInteractiveHistoryService);
|
||||
const kernelService = accessor.get(INotebookKernelService);
|
||||
const group = viewColumnToEditorGroup(editorGroupService, column);
|
||||
const group = columnToEditorGroup(editorGroupService, column);
|
||||
|
||||
if (resource && resource.scheme === Schemas.vscodeInteractive) {
|
||||
const resourceUri = URI.revive(resource);
|
||||
|
|
|
@ -9,7 +9,8 @@ import { Action2, ICommandActionTitle, MenuId, registerAction2 } from 'vs/platfo
|
|||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ActiveEditorContext, viewColumnToEditorGroup } from 'vs/workbench/common/editor';
|
||||
import { ActiveEditorContext } from 'vs/workbench/common/editor';
|
||||
import { columnToEditorGroup } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import { DiffElementViewModelBase } from 'vs/workbench/contrib/notebook/browser/diff/diffElementViewModel';
|
||||
import { NOTEBOOK_DIFF_CELL_PROPERTY, NOTEBOOK_DIFF_CELL_PROPERTY_EXPANDED } from 'vs/workbench/contrib/notebook/browser/diff/notebookDiffEditorBrowser';
|
||||
import { NotebookTextDiffEditor } from 'vs/workbench/contrib/notebook/browser/diff/notebookTextDiffEditor';
|
||||
|
@ -55,7 +56,7 @@ registerAction2(class extends Action2 {
|
|||
preserveFocus: false,
|
||||
override: EditorOverride.DISABLED
|
||||
}
|
||||
}, viewColumnToEditorGroup(editorGroupService, undefined));
|
||||
}, columnToEditorGroup(editorGroupService, undefined));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
|||
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { findGroup } from 'vs/workbench/services/editor/browser/editorGroupFinder';
|
||||
import { findGroup } from 'vs/workbench/services/editor/common/editorGroupFinder';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { PreferredGroup } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import { RegisteredEditorPriority, IEditorOverrideService, OverrideStatus } from
|
|||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IWorkspaceTrustRequestService, WorkspaceTrustUriResponse } from 'vs/platform/workspace/common/workspaceTrust';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { findGroup } from 'vs/workbench/services/editor/browser/editorGroupFinder';
|
||||
import { findGroup } from 'vs/workbench/services/editor/common/editorGroupFinder';
|
||||
|
||||
type CachedEditorInput = TextResourceEditorInput | IFileEditorInput | UntitledTextEditorInput;
|
||||
|
||||
|
|
42
src/vs/workbench/services/editor/common/editorGroupColumn.ts
Normal file
42
src/vs/workbench/services/editor/common/editorGroupColumn.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { GroupIdentifier } from 'vs/workbench/common/editor';
|
||||
import { IEditorGroupsService, GroupsOrder, IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
/**
|
||||
* A way to address editor groups through a column based system
|
||||
* where `0` is the first column. Will fallback to `SIDE_GROUP`
|
||||
* in case the column does not exist yet.
|
||||
*/
|
||||
export type EditorGroupColumn = number;
|
||||
|
||||
export function columnToEditorGroup(editorGroupService: IEditorGroupsService, column?: EditorGroupColumn): GroupIdentifier {
|
||||
if (typeof column !== 'number' || column === ACTIVE_GROUP) {
|
||||
return ACTIVE_GROUP; // prefer active group when position is undefined or passed in as such
|
||||
}
|
||||
|
||||
const groups = editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE);
|
||||
|
||||
let candidateGroup = groups[column];
|
||||
if (candidateGroup) {
|
||||
return candidateGroup.id; // found direct match
|
||||
}
|
||||
|
||||
let firstGroup = groups[0];
|
||||
if (groups.length === 1 && firstGroup.count === 0) {
|
||||
return firstGroup.id; // first editor should always open in first group independent from position provided
|
||||
}
|
||||
|
||||
return SIDE_GROUP; // open to the side if group not found or we are instructed to
|
||||
}
|
||||
|
||||
export function editorGroupToColumn(editorGroupService: IEditorGroupsService, editorGroup: IEditorGroup | GroupIdentifier): EditorGroupColumn {
|
||||
let group = (typeof editorGroup === 'number') ? editorGroupService.getGroup(editorGroup) : editorGroup;
|
||||
group = group ?? editorGroupService.activeGroup;
|
||||
|
||||
return editorGroupService.getGroups(GroupsOrder.GRID_APPEARANCE).indexOf(group);
|
||||
}
|
|
@ -16,7 +16,7 @@ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
|
|||
import { ExtHostWebviews } from 'vs/workbench/api/common/extHostWebview';
|
||||
import { ExtHostWebviewPanels } from 'vs/workbench/api/common/extHostWebviewPanels';
|
||||
import { webviewResourceBaseHost } from 'vs/workbench/api/common/shared/webview';
|
||||
import { EditorGroupColumn } from 'vs/workbench/common/editor';
|
||||
import { EditorGroupColumn } from 'vs/workbench/services/editor/common/editorGroupColumn';
|
||||
import type * as vscode from 'vscode';
|
||||
import { SingleProxyRPCProtocol } from './testRPCProtocol';
|
||||
|
||||
|
|
Loading…
Reference in a new issue