Explorar el Código

Passes additional args to webview show command

main
Eric Amodio hace 2 años
padre
commit
d764b01614
Se han modificado 5 ficheros con 36 adiciones y 34 borrados
  1. +3
    -2
      src/plus/webviews/graph/graphWebview.ts
  2. +2
    -2
      src/plus/webviews/timeline/timelineWebview.ts
  3. +28
    -1
      src/webviews/settings/settingsWebview.ts
  4. +3
    -3
      src/webviews/webviewBase.ts
  5. +0
    -26
      src/webviews/webviewWithConfigBase.ts

+ 3
- 2
src/plus/webviews/graph/graphWebview.ts Ver fichero

@ -59,9 +59,10 @@ export class GraphWebview extends WebviewWithConfigBase {
this.disposables.push({ dispose: () => void this.repoDisposable?.dispose() });
}
override async show(column: ViewColumn = ViewColumn.Active): Promise<void> {
override async show(column: ViewColumn = ViewColumn.Active, ...args: any[]): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
return super.show(column);
return super.show(column, ...args);
}
private _theme: ColorTheme | undefined;

+ 2
- 2
src/plus/webviews/timeline/timelineWebview.ts Ver fichero

@ -62,9 +62,9 @@ export class TimelineWebview extends WebviewBase {
};
}
override async show(column: ViewColumn = ViewColumn.Beside): Promise<void> {
override async show(column: ViewColumn = ViewColumn.Beside, ...args: any[]): Promise<void> {
if (!(await ensurePlusFeaturesEnabled())) return;
return super.show(column);
return super.show(column, ...args);
}
protected override onInitializing(): Disposable[] | undefined {

+ 28
- 1
src/webviews/settings/settingsWebview.ts Ver fichero

@ -3,12 +3,15 @@ import { configuration } from '../../configuration';
import { Commands } from '../../constants';
import type { Container } from '../../container';
import { registerCommand } from '../../system/command';
import { DidOpenAnchorNotificationType } from '../protocol';
import { WebviewWithConfigBase } from '../webviewWithConfigBase';
import type { State } from './protocol';
const anchorRegex = /.*?#(.*)/;
export class SettingsWebview extends WebviewWithConfigBase<State> {
private _pendingJumpToAnchor: string | undefined;
constructor(container: Container) {
super(
container,
@ -42,11 +45,35 @@ export class SettingsWebview extends WebviewWithConfigBase {
[, anchor] = match;
}
return registerCommand(c, () => this.onShowCommand(anchor), this);
return registerCommand(c, (...args: any[]) => this.onShowAnchorCommand(anchor, ...args), this);
}),
);
}
protected override onReady() {
if (this._pendingJumpToAnchor != null) {
const anchor = this._pendingJumpToAnchor;
this._pendingJumpToAnchor = undefined;
void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'auto' });
}
}
private onShowAnchorCommand(anchor?: string, ...args: any[]) {
if (anchor) {
if (this.isReady && this.visible) {
queueMicrotask(
() => void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'smooth' }),
);
return;
}
this._pendingJumpToAnchor = anchor;
}
this.onShowCommand(...args);
}
protected override includeBootstrap(): State {
const scopes: ['user' | 'workspace', string][] = [['user', 'User']];
if (workspace.workspaceFolders?.length) {

+ 3
- 3
src/webviews/webviewBase.ts Ver fichero

@ -63,7 +63,7 @@ export abstract class WebviewBase implements Disposable {
this._panel?.dispose();
}
async show(column: ViewColumn = ViewColumn.Beside): Promise<void> {
async show(column: ViewColumn = ViewColumn.Beside, ..._args: any[]): Promise<void> {
// Only try to open beside if there is an active tab
if (column === ViewColumn.Beside && window.tabGroups.activeTabGroup.activeTab == null) {
column = ViewColumn.Active;
@ -137,8 +137,8 @@ export abstract class WebviewBase implements Disposable {
this._panel = undefined;
}
protected onShowCommand(): void {
void this.show();
protected onShowCommand(...args: any[]): void {
void this.show(undefined, ...args);
}
protected onViewStateChanged(e: WebviewPanelOnDidChangeViewStateEvent): void {

+ 0
- 26
src/webviews/webviewWithConfigBase.ts Ver fichero

@ -12,7 +12,6 @@ import type { IpcMessage } from './protocol';
import {
DidChangeConfigurationNotificationType,
DidGenerateConfigurationPreviewNotificationType,
DidOpenAnchorNotificationType,
GenerateConfigurationPreviewCommandType,
onIpc,
UpdateConfigurationCommandType,
@ -20,8 +19,6 @@ import {
import { WebviewBase } from './webviewBase';
export abstract class WebviewWithConfigBase<State> extends WebviewBase<State> {
private _pendingJumpToAnchor: string | undefined;
constructor(
container: Container,
id: `gitlens.${string}`,
@ -55,29 +52,6 @@ export abstract class WebviewWithConfigBase extends WebviewBase {
void this.notifyDidChangeConfiguration();
}
protected override onReady() {
if (this._pendingJumpToAnchor != null) {
const anchor = this._pendingJumpToAnchor;
this._pendingJumpToAnchor = undefined;
void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'auto' });
}
}
protected override onShowCommand(anchor?: string) {
if (anchor) {
if (this.isReady && this.visible) {
queueMicrotask(
() => void this.notify(DidOpenAnchorNotificationType, { anchor: anchor, scrollBehavior: 'smooth' }),
);
return;
}
this._pendingJumpToAnchor = anchor;
}
super.onShowCommand();
}
protected override onViewStateChanged(e: WebviewPanelOnDidChangeViewStateEvent): void {
super.onViewStateChanged(e);

Cargando…
Cancelar
Guardar