瀏覽代碼

Adds experimental multi-instance support to Graph

main
Eric Amodio 1 年之前
父節點
當前提交
7e84331f21
共有 4 個文件被更改,包括 28 次插入5 次删除
  1. +7
    -0
      package.json
  2. +3
    -0
      src/config.ts
  3. +1
    -1
      src/plus/webviews/graph/graphWebview.ts
  4. +17
    -4
      src/plus/webviews/graph/registration.ts

+ 7
- 0
package.json 查看文件

@ -2465,6 +2465,13 @@
"markdownDescription": "Specifies additional markers to show on the minimap in the _Commit Graph_",
"scope": "window",
"order": 102
},
"gitlens.graph.experimental.allowMultipleInstances": {
"type": "boolean",
"default": false,
"markdownDescription": "Specifies whether to allow opening multiple instances of the _Commit Graph_ in the editor area",
"scope": "window",
"order": 110
}
}
},

+ 3
- 0
src/config.ts 查看文件

@ -321,6 +321,9 @@ export interface GraphConfig {
readonly dateStyle: DateStyle | null;
readonly defaultItemLimit: number;
readonly dimMergeCommits: boolean;
readonly experimental: {
allowMultipleInstances: boolean;
};
readonly minimap: {
readonly enabled: boolean;
readonly dataType: 'commits' | 'lines';

+ 1
- 1
src/plus/webviews/graph/graphWebview.ts 查看文件

@ -372,7 +372,7 @@ export class GraphWebviewProvider implements WebviewProvider {
() =>
void executeCommand<WebviewPanelShowCommandArgs>(
Commands.ShowGraphPage,
undefined,
{ _type: 'WebviewPanelShowOptions', preserveInstance: true },
this.repository,
),
),

+ 17
- 4
src/plus/webviews/graph/registration.ts 查看文件

@ -19,7 +19,7 @@ import type { ShowInCommitGraphCommandArgs, State } from './protocol';
export function registerGraphWebviewPanel(controller: WebviewsController) {
return controller.registerWebviewPanel<State>(
{ id: Commands.ShowGraphPage },
{ id: Commands.ShowGraphPage, options: { preserveInstance: false } },
{
id: 'gitlens.graph',
fileName: 'graph.html',
@ -33,6 +33,7 @@ export function registerGraphWebviewPanel(controller: WebviewsController) {
retainContextWhenHidden: true,
enableFindWidget: false,
},
allowMultipleInstances: configuration.get('graph.experimental.allowMultipleInstances'),
},
async (container, host) => {
const { GraphWebviewProvider } = await import(/* webpackChunkName: "graph" */ './graphWebview');
@ -66,11 +67,22 @@ export function registerGraphWebviewCommands(container: Container, panels: Webvi
registerCommand(Commands.ShowGraph, (...args: unknown[]) =>
configuration.get('graph.layout') === 'panel'
? executeCommand(Commands.ShowGraphView, ...args)
: executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage, undefined, ...args),
: executeCommand<WebviewPanelShowCommandArgs>(
Commands.ShowGraphPage,
{ _type: 'WebviewPanelShowOptions', preserveInstance: true },
undefined,
...args,
),
),
registerCommand(`${panels.id}.switchToEditorLayout`, async () => {
await configuration.updateEffective('graph.layout', 'editor');
queueMicrotask(() => void executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage));
queueMicrotask(
() =>
void executeCommand<WebviewPanelShowCommandArgs>(Commands.ShowGraphPage, {
_type: 'WebviewPanelShowOptions',
preserveInstance: true,
}),
);
}),
registerCommand(`${panels.id}.switchToPanelLayout`, async () => {
await configuration.updateEffective('graph.layout', 'panel');
@ -111,7 +123,8 @@ export function registerGraphWebviewCommands(container: Container, panels: Webvi
if (configuration.get('graph.layout') === 'panel') {
void container.graphView.show({ preserveFocus: preserveFocus }, args);
} else {
void panels.show({ preserveFocus: preserveFocus }, args);
const active = panels.getActiveInstance()?.instanceId;
void panels.show({ preserveFocus: preserveFocus, preserveInstance: active ?? true }, args);
}
},
),

Loading…
取消
儲存