From f7941b4f4b4e5ca6ab860366776c3ffc3decd5e5 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Mon, 1 May 2023 19:04:54 -0400 Subject: [PATCH] Adds VFW to context menus --- package.json | 35 +++++++++++++++++++++++---- src/plus/webviews/timeline/timelineWebview.ts | 11 ++++++--- src/views/nodes/viewNode.ts | 4 +++ 3 files changed, 42 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 73423bd..45a003a 100644 --- a/package.json +++ b/package.json @@ -4661,7 +4661,7 @@ }, { "command": "gitlens.showTimelinePage", - "title": "Open Visual File History of Active File", + "title": "Open Visual File History", "category": "GitLens+", "icon": "$(gitlens-history)" }, @@ -9463,11 +9463,16 @@ "group": "2_gitlens_1@1" }, { - "command": "gitlens.quickOpenFileHistory", + "command": "gitlens.showTimelinePage", "when": "gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editor.history && resourceScheme != output", "group": "2_gitlens_1@2" }, { + "command": "gitlens.quickOpenFileHistory", + "when": "gitlens:activeFileStatus =~ /tracked/ && config.gitlens.menus.editor.history && resourceScheme != output", + "group": "2_gitlens_1@3" + }, + { "submenu": "gitlens/editor/annotations", "when": "editorTextFocus && gitlens:activeFileStatus =~ /blameable/ && config.gitlens.menus.editor.blame && resourceScheme != output", "group": "2_gitlens_2@1" @@ -9707,9 +9712,14 @@ "group": "2_gitlens_1@1" }, { - "command": "gitlens.quickOpenFileHistory", + "command": "gitlens.showTimelinePage", "when": "gitlens:enabled && config.gitlens.menus.editorTab.history && isFileSystemResource", "group": "2_gitlens_1@2" + }, + { + "command": "gitlens.quickOpenFileHistory", + "when": "gitlens:enabled && config.gitlens.menus.editorTab.history && isFileSystemResource", + "group": "2_gitlens_1@3" } ], "explorer/context": [ @@ -9741,11 +9751,16 @@ "group": "4_timeline@2" }, { - "command": "gitlens.quickOpenFileHistory", + "command": "gitlens.showTimelinePage", "when": "!explorerResourceIsRoot && !explorerResourceIsFolder && gitlens:enabled && config.gitlens.menus.explorer.history", "group": "4_timeline@3" }, { + "command": "gitlens.quickOpenFileHistory", + "when": "!explorerResourceIsRoot && !explorerResourceIsFolder && gitlens:enabled && config.gitlens.menus.explorer.history", + "group": "4_timeline@4" + }, + { "command": "gitlens.copyRemoteFileUrlWithoutRange", "when": "!explorerResourceIsRoot && !explorerResourceIsFolder && gitlens:enabled && gitlens:hasRemotes && config.gitlens.menus.explorer.clipboard", "group": "6_copypath@100" @@ -9887,9 +9902,14 @@ "group": "4_timeline@2" }, { - "command": "gitlens.quickOpenFileHistory", + "command": "gitlens.showTimelinePage", "when": "gitlens:enabled && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.history", "group": "4_timeline@3" + }, + { + "command": "gitlens.quickOpenFileHistory", + "when": "gitlens:enabled && scmProvider == git && scmResourceGroup =~ /^(workingTree|index|merge)$/ && config.gitlens.menus.scmItem.history", + "group": "4_timeline@4" } ], "timeline/item/context": [ @@ -11118,6 +11138,11 @@ "group": "2_gitlens_quickopen@6" }, { + "command": "gitlens.showTimelinePage", + "when": "viewItem =~ /gitlens:file\\b/", + "group": "2_gitlens_quickopen@7" + }, + { "submenu": "gitlens/commit/file/commit", "when": "view =~ /^gitlens\\.views\\.(fileHistory|lineHistory)/ && viewItem =~ /gitlens:file\\b(?=.*?\\b\\+committed\\b)/", "group": "3_gitlens_explore@1" diff --git a/src/plus/webviews/timeline/timelineWebview.ts b/src/plus/webviews/timeline/timelineWebview.ts index 2bfc7a9..abd30ee 100644 --- a/src/plus/webviews/timeline/timelineWebview.ts +++ b/src/plus/webviews/timeline/timelineWebview.ts @@ -17,6 +17,7 @@ import type { Deferrable } from '../../../system/function'; import { debounce } from '../../../system/function'; import { filter } from '../../../system/iterable'; import { hasVisibleTextEditor, isTextEditor } from '../../../system/utils'; +import { isViewFileNode } from '../../../views/nodes/viewNode'; import type { IpcMessage } from '../../../webviews/protocol'; import { onIpc } from '../../../webviews/protocol'; import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController'; @@ -81,9 +82,13 @@ export class TimelineWebviewProvider implements WebviewProvider { _options: { column?: ViewColumn; preserveFocus?: boolean }, ...args: unknown[] ): boolean { - const [uri] = args; - if (uri != null && uri instanceof Uri) { - this.updatePendingUri(uri); + const [uriOrNode] = args; + if (uriOrNode != null) { + if (uriOrNode instanceof Uri) { + this.updatePendingUri(uriOrNode); + } else if (isViewFileNode(uriOrNode)) { + this.updatePendingUri(uriOrNode.uri); + } } else { this.updatePendingEditor(window.activeTextEditor); } diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index d1e5e57..6e5588e 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -165,6 +165,10 @@ export function isViewNode(node: any): node is ViewNode { return node instanceof ViewNode; } +export function isViewFileNode(node: any): node is ViewFileNode { + return node instanceof ViewFileNode; +} + type StateKey = keyof T; type StateValue> = P extends keyof T ? T[P] : never;