浏览代码

Fixes poor experience w/ resetting view locations

main
Eric Amodio 1年前
父节点
当前提交
264be51f66
共有 8 个文件被更改,包括 100 次插入33 次删除
  1. +19
    -5
      src/commands/resetViewsLayout.ts
  2. +6
    -4
      src/config.ts
  3. +60
    -2
      src/constants.ts
  4. +2
    -2
      src/plus/webviews/graph/registration.ts
  5. +5
    -13
      src/system/command.ts
  6. +4
    -3
      src/views/viewBase.ts
  7. +2
    -2
      src/webviews/webviewController.ts
  8. +2
    -2
      src/webviews/webviewsController.ts

+ 19
- 5
src/commands/resetViewsLayout.ts 查看文件

@ -1,7 +1,7 @@
import { viewsConfigKeys } from '../config';
import { Commands } from '../constants';
import type { QualifiedViewIds } from '../constants';
import { Commands, viewIdsByDefaultContainerId } from '../constants';
import type { Container } from '../container';
import { command, executeCommand } from '../system/command';
import { command, executeCoreCommand } from '../system/command';
import { Command } from './base';
@command()
@ -11,8 +11,22 @@ export class ResetViewsLayoutCommand extends Command {
}
async execute() {
for (const view of viewsConfigKeys) {
void (await executeCommand(`gitlens.views.${view}.resetViewLocation`));
// Don't use this because it will forcibly show & expand every view
// for (const view of viewIds) {
// void (await executeCoreCommand(`gitlens.views.${view}.resetViewLocation`));
// }
for (const [containerId, viewIds] of viewIdsByDefaultContainerId) {
try {
void (await executeCoreCommand('vscode.moveViews', {
viewIds: viewIds.map<QualifiedViewIds>(v => `gitlens.views.${v}`),
destinationId: containerId,
}));
} catch {}
if (containerId.includes('gitlens')) {
void (await executeCoreCommand(`${containerId}.resetViewContainerLocation`));
}
}
}
}

+ 6
- 4
src/config.ts 查看文件

@ -662,16 +662,18 @@ interface ViewsConfigs {
export type ViewsConfigKeys = keyof ViewsConfigs;
export const viewsConfigKeys: ViewsConfigKeys[] = [
'branches',
'commits',
'repositories',
'commitDetails',
'contributors',
'fileHistory',
'lineHistory',
'branches',
'remotes',
'repositories',
'searchAndCompare',
'stashes',
'tags',
'contributors',
'searchAndCompare',
'workspaces',
'worktrees',
];

+ 60
- 2
src/constants.ts 查看文件

@ -316,8 +316,64 @@ export const enum Commands {
}
export type CustomEditorIds = 'rebase';
export type TreeViewIds =
| 'branches'
| 'commits'
| 'contributors'
| 'fileHistory'
| 'lineHistory'
| 'remotes'
| 'repositories'
| 'searchAndCompare'
| 'stashes'
| 'tags'
| 'workspaces'
| 'worktrees';
export type WebviewIds = 'graph' | 'settings' | 'timeline' | 'welcome' | 'focus';
export type WebviewViewIds = 'commitDetails' | 'graph' | 'graphDetails' | 'home' | 'timeline' | 'account';
export type WebviewViewIds = 'account' | 'commitDetails' | 'graph' | 'graphDetails' | 'home' | 'timeline';
export type ViewIds = TreeViewIds | WebviewViewIds;
export type QualifiedViewIds = `gitlens.views.${ViewIds}`;
export type ViewContainerIds = 'gitlens' | 'gitlensInspect' | 'gitlensPanel';
export type QualifiedViewContainerIds = `workbench.view.extension.${ViewContainerIds}`;
export type CoreViewContainerIds = 'scm';
export type QualifiedCoreViewContainerIds = `workbench.view.${CoreViewContainerIds}`;
// export const viewIds: ViewIds[] = [
// 'account',
// 'branches',
// 'commits',
// 'commitDetails',
// 'contributors',
// 'fileHistory',
// 'graph',
// 'graphDetails',
// 'home',
// 'lineHistory',
// 'remotes',
// 'repositories',
// 'searchAndCompare',
// 'stashes',
// 'tags',
// 'timeline',
// 'workspaces',
// 'worktrees',
// ];
export const viewIdsByDefaultContainerId = new Map<
QualifiedViewContainerIds | QualifiedCoreViewContainerIds,
ViewIds[]
>([
['workbench.view.scm', ['branches', 'commits', 'remotes', 'repositories', 'stashes', 'tags', 'worktrees']],
['workbench.view.extension.gitlensPanel', ['graph', 'graphDetails']],
[
'workbench.view.extension.gitlensInspect',
['commitDetails', 'fileHistory', 'lineHistory', 'timeline', 'searchAndCompare'],
],
['workbench.view.extension.gitlens', ['home', 'workspaces', 'contributors', 'account']],
]);
export type ContextKeys =
| `${typeof extensionPrefix}:action:${string}`
@ -387,7 +443,9 @@ export type CoreCommands =
| 'workbench.extensions.uninstallExtension'
| 'workbench.files.action.focusFilesExplorer'
| 'workbench.view.explorer'
| 'workbench.view.scm';
| 'workbench.view.scm'
| `${QualifiedViewContainerIds | QualifiedCoreViewContainerIds}.resetViewContainerLocation`
| `${QualifiedViewIds}.${'focus' | 'removeView' | 'resetViewLocation' | 'toggleVisibility'}`;
export type CoreGitCommands =
| 'git.fetch'

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

@ -73,8 +73,8 @@ export function registerGraphWebviewCommands(container: Container, webview: Webv
registerCommand('gitlens.graph.switchToPanelLayout', async () => {
await configuration.updateEffective('graph.layout', 'panel');
queueMicrotask(async () => {
await executeCommand('gitlens.views.graph.resetViewLocation');
await executeCommand('gitlens.views.graphDetails.resetViewLocation');
await executeCoreCommand('gitlens.views.graph.resetViewLocation');
await executeCoreCommand('gitlens.views.graphDetails.resetViewLocation');
void executeCommand(Commands.ShowGraphView);
});
}),

+ 5
- 13
src/system/command.ts 查看文件

@ -42,9 +42,7 @@ export function executeActionCommand(action: Action,
return commands.executeCommand(`${Commands.ActionPrefix}${action}`, { ...args, type: action });
}
type SupportedCommands = Commands | `gitlens.views.${string}.focus` | `gitlens.views.${string}.resetViewLocation`;
export function createCommand<T extends unknown[]>(command: SupportedCommands, title: string, ...args: T): CoreCommand {
export function createCommand<T extends unknown[]>(command: Commands, title: string, ...args: T): CoreCommand {
return {
command: command,
title: title,
@ -52,16 +50,10 @@ export function createCommand(command: SupportedCommands, t
};
}
export function executeCommand<U = any>(command: SupportedCommands): Thenable<U>;
export function executeCommand<T = unknown, U = any>(command: SupportedCommands, arg: T): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(
command: SupportedCommands,
...args: T
): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(
command: SupportedCommands,
...args: T
): Thenable<U> {
export function executeCommand<U = any>(command: Commands): Thenable<U>;
export function executeCommand<T = unknown, U = any>(command: Commands, arg: T): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(command: Commands, ...args: T): Thenable<U>;
export function executeCommand<T extends [...unknown[]] = [], U = any>(command: Commands, ...args: T): Thenable<U> {
return commands.executeCommand<U>(command, ...args);
}

+ 4
- 3
src/views/viewBase.ts 查看文件

@ -28,8 +28,9 @@ import type {
WorktreesViewConfig,
} from '../config';
import { viewsCommonConfigKeys, viewsConfigKeys } from '../config';
import type { TreeViewIds } from '../constants';
import type { Container } from '../container';
import { executeCommand } from '../system/command';
import { executeCoreCommand } from '../system/command';
import { configuration } from '../system/configuration';
import { debug, log } from '../system/decorators/log';
import { once } from '../system/event';
@ -137,7 +138,7 @@ export abstract class ViewBase<
constructor(
public readonly container: Container,
public readonly id: `gitlens.views.${ViewsConfigKeys}`,
public readonly id: `gitlens.views.${TreeViewIds}`,
public readonly name: string,
private readonly trackingFeature: TrackedUsageFeatures,
) {
@ -591,7 +592,7 @@ export abstract class ViewBase<
const scope = getLogScope();
try {
void (await executeCommand(`${this.id}.focus`, options));
void (await executeCoreCommand(`${this.id}.focus`, options));
} catch (ex) {
Logger.error(ex, scope);
}

+ 2
- 2
src/webviews/webviewController.ts 查看文件

@ -3,7 +3,7 @@ import { Disposable, EventEmitter, Uri, ViewColumn, window, workspace } from 'vs
import { getNonce } from '@env/crypto';
import type { Commands, CustomEditorIds, WebviewIds, WebviewViewIds } from '../constants';
import type { Container } from '../container';
import { executeCommand } from '../system/command';
import { executeCommand, executeCoreCommand } from '../system/command';
import { setContext } from '../system/context';
import { debug, logName } from '../system/decorators/log';
import { serialize } from '../system/decorators/serialize';
@ -269,7 +269,7 @@ export class WebviewController<
);
}
} else if (this.isView()) {
await executeCommand(`${this.id}.focus`, options);
await executeCoreCommand(`${this.id}.focus`, options);
if (loading) {
this.provider.onVisibilityChanged?.(true);
}

+ 2
- 2
src/webviews/webviewsController.ts 查看文件

@ -10,7 +10,7 @@ import { Disposable, Uri, ViewColumn, window } from 'vscode';
import type { Commands, WebviewIds, WebviewViewIds } from '../constants';
import type { Container } from '../container';
import { ensurePlusFeaturesEnabled } from '../plus/subscription/utils';
import { executeCommand, registerCommand } from '../system/command';
import { executeCoreCommand, registerCommand } from '../system/command';
import { debug } from '../system/decorators/log';
import { Logger } from '../system/logger';
import { getLogScope } from '../system/logger.scope';
@ -191,7 +191,7 @@ export class WebviewsController implements Disposable {
Logger.debug(scope, `Showing webview view (${descriptor.id})`);
registration.pendingShowArgs = [options, ...args];
return void executeCommand(`${descriptor.id}.focus`, options);
return void executeCoreCommand(`${descriptor.id}.focus`, options);
},
} satisfies WebviewViewProxy;
}

正在加载...
取消
保存