Browse Source

Adds experimental multi-instance support to Graph

main
Eric Amodio 1 year ago
parent
commit
7e84331f21
4 changed files with 28 additions and 5 deletions
  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 View File

@ -2465,6 +2465,13 @@
"markdownDescription": "Specifies additional markers to show on the minimap in the _Commit Graph_", "markdownDescription": "Specifies additional markers to show on the minimap in the _Commit Graph_",
"scope": "window", "scope": "window",
"order": 102 "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 View File

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

+ 1
- 1
src/plus/webviews/graph/graphWebview.ts View File

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

+ 17
- 4
src/plus/webviews/graph/registration.ts View File

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

Loading…
Cancel
Save