Bladeren bron

Expands openWorkspace options

main
Eric Amodio 3 jaren geleden
bovenliggende
commit
637f9d9c27
2 gewijzigde bestanden met toevoegingen van 27 en 12 verwijderingen
  1. +12
    -3
      src/commands/browseRepoAtRevision.ts
  2. +15
    -9
      src/commands/common.ts

+ 12
- 3
src/commands/browseRepoAtRevision.ts Bestand weergeven

@ -7,7 +7,15 @@ import { toGitLensFSUri } from '../git/fsProvider';
import { GitUri } from '../git/gitUri';
import { Logger } from '../logger';
import { Messages } from '../messages';
import { ActiveEditorCommand, command, CommandContext, Commands, getCommandUri, openWorkspace } from './common';
import {
ActiveEditorCommand,
command,
CommandContext,
Commands,
getCommandUri,
openWorkspace,
OpenWorkspaceLocation,
} from './common';
export interface BrowseRepoAtRevisionCommandArgs {
uri?: Uri;
@ -63,8 +71,9 @@ export class BrowseRepoAtRevisionCommand extends ActiveEditorCommand {
uri = toGitLensFSUri(sha, gitUri.repoPath!);
gitUri = GitUri.fromRevisionUri(uri);
openWorkspace(uri, `${paths.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`, {
openInNewWindow: args.openInNewWindow,
openWorkspace(uri, {
location: args.openInNewWindow ? OpenWorkspaceLocation.NewWindow : OpenWorkspaceLocation.AddToWorkspace,
name: `${paths.basename(gitUri.repoPath!)} @ ${gitUri.shortSha}`,
});
if (!args.openInNewWindow) {

+ 15
- 9
src/commands/common.ts Bestand weergeven

@ -732,16 +732,22 @@ export async function openEditor(
}
}
export function openWorkspace(uri: Uri, name: string, options: { openInNewWindow?: boolean } = {}) {
if (options.openInNewWindow) {
void commands.executeCommand(BuiltInCommands.OpenFolder, uri, true);
export enum OpenWorkspaceLocation {
CurrentWindow = 'currentWindow',
NewWindow = 'newWindow',
AddToWorkspace = 'addToWorkspace',
}
return true;
export function openWorkspace(
uri: Uri,
options: { location?: OpenWorkspaceLocation; name?: string } = { location: OpenWorkspaceLocation.CurrentWindow },
): void {
if (options?.location === OpenWorkspaceLocation.AddToWorkspace) {
const count = workspace.workspaceFolders?.length ?? 0;
return void workspace.updateWorkspaceFolders(count, 0, { uri: uri, name: options?.name });
}
return workspace.updateWorkspaceFolders(
workspace.workspaceFolders != null ? workspace.workspaceFolders.length : 0,
null,
{ uri: uri, name: name },
);
return void commands.executeCommand(BuiltInCommands.OpenFolder, uri, {
forceNewWindow: options?.location === OpenWorkspaceLocation.NewWindow,
});
}

Laden…
Annuleren
Opslaan