|
@ -1,8 +1,10 @@ |
|
|
import { env, TextEditor, Uri } from 'vscode'; |
|
|
|
|
|
|
|
|
import type { TextEditor, Uri } from 'vscode'; |
|
|
|
|
|
import { env } from 'vscode'; |
|
|
import { Commands } from '../constants'; |
|
|
import { Commands } from '../constants'; |
|
|
import type { Container } from '../container'; |
|
|
import type { Container } from '../container'; |
|
|
import { command } from '../system/command'; |
|
|
import { command } from '../system/command'; |
|
|
import { ActiveEditorCommand, getCommandUri } from './base'; |
|
|
|
|
|
|
|
|
import type { CommandContext } from './base'; |
|
|
|
|
|
import { ActiveEditorCommand, getCommandUri, isCommandContextViewNodeHasFileCommit } from './base'; |
|
|
|
|
|
|
|
|
@command() |
|
|
@command() |
|
|
export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { |
|
|
export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { |
|
@ -10,6 +12,14 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { |
|
|
super(Commands.CopyRelativePathToClipboard); |
|
|
super(Commands.CopyRelativePathToClipboard); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override preExecute(context: CommandContext) { |
|
|
|
|
|
if (isCommandContextViewNodeHasFileCommit(context)) { |
|
|
|
|
|
return this.execute(context.editor, context.node.commit.file!.uri); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return this.execute(context.editor, context.uri); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async execute(editor?: TextEditor, uri?: Uri) { |
|
|
async execute(editor?: TextEditor, uri?: Uri) { |
|
|
uri = getCommandUri(uri, editor); |
|
|
uri = getCommandUri(uri, editor); |
|
|
let relativePath = ''; |
|
|
let relativePath = ''; |
|
@ -20,7 +30,7 @@ export class CopyRelativePathToClipboardCommand extends ActiveEditorCommand { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void (await env.clipboard.writeText(relativePath)); |
|
|
|
|
|
|
|
|
await env.clipboard.writeText(relativePath); |
|
|
return undefined; |
|
|
return undefined; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |