-
Notifications
You must be signed in to change notification settings - Fork 9
Feat: add button at scm title #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2a1c8ae
1d90605
9a4858c
9fd65ce
298c495
9b2e6dc
88cb99a
d80302e
0f180c0
994dddf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,14 +77,27 @@ | |
| { | ||
| "category": "(neo) Git Graph", | ||
| "command": "neo-git-graph.view", | ||
| "title": "%command.view%" | ||
| "title": "%command.view%", | ||
| "icon": { | ||
| "light": "resources/webview-icon-light.svg", | ||
| "dark": "resources/webview-icon-dark.svg" | ||
| } | ||
| }, | ||
| { | ||
| "category": "(neo) Git Graph", | ||
| "command": "neo-git-graph.clearAvatarCache", | ||
| "title": "%command.clearAvatarCache%" | ||
| } | ||
| ], | ||
| "menus": { | ||
| "scm/title": [ | ||
| { | ||
| "command": "neo-git-graph.view", | ||
| "group": "navigation", | ||
| "when": "scmProvider == git" | ||
| } | ||
| ] | ||
| }, | ||
|
Comment on lines
+80
to
+100
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code alone can do the job without modifying/adding any other code. The existing command handler can handle the active/current repo state by itself. So, you can remove the other changes. Any future issues will be solved independently.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only adding this code will result in it only open the last repo when face multi repo. I think if without the auto switch repo function, the PR will give a scm title button with bug. You mean I should put it split into two PR, or you will solve this questions yourself?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think we can split the PR. You can propose the fix for the multi-repo issue. But be aware that I'm preparing to release a new version. After releasing it, I'll be working on the initialization logic that may affect this issue. |
||
| "configuration": { | ||
| "type": "object", | ||
| "title": "%config.title%", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ import * as vscode from "vscode"; | |
|
|
||
| import { AvatarManager } from "./avatarManager"; | ||
| import { gitClientFactory } from "./backend/gitClient"; | ||
| import { buildExtensionUri } from "./backend/utils/path.util"; | ||
| import { buildExtensionUri, getPathFromStr } from "./backend/utils/path.util"; | ||
| import { config } from "./config"; | ||
| import { DiffDocProvider } from "./diffDocProvider"; | ||
| import { registerMessageHandlers } from "./extension/messageHandler"; | ||
|
|
@@ -28,6 +28,7 @@ export function activate(context: vscode.ExtensionContext) { | |
| const repoSearch = createRepoSearch(repoManager, config); | ||
| const repoWatcher = createRepoWatcher(repoManager, config, repoSearch); | ||
| let currentPanel: WebviewPanel | undefined; | ||
| let currentBridge: WebviewBridge | undefined; | ||
|
|
||
| void (async () => { | ||
| repoManager.removeReposNotInWorkspace(); | ||
|
|
@@ -38,9 +39,34 @@ export function activate(context: vscode.ExtensionContext) { | |
|
|
||
| context.subscriptions.push( | ||
| outputChannel, | ||
| vscode.commands.registerCommand("neo-git-graph.view", () => { | ||
| vscode.commands.registerCommand("neo-git-graph.view", (resource) => { | ||
| let repoPath: string | undefined; | ||
|
|
||
| if (resource && typeof resource === "object") { | ||
| if (typeof resource?.rootUri?.fsPath === "string") { | ||
| repoPath = getPathFromStr(resource.rootUri.fsPath); | ||
| } else if (typeof resource?.uri?.fsPath === "string") { | ||
| repoPath = getPathFromStr(resource.uri.fsPath); | ||
| } | ||
| } | ||
|
Chzxxuanzheng marked this conversation as resolved.
|
||
|
|
||
|
Comment on lines
+48
to
+52
|
||
| const repos = repoManager.getRepos(); | ||
|
|
||
| if (repoPath && !repos[repoPath]) repoPath = undefined; | ||
|
|
||
| const column = vscode.window.activeTextEditor?.viewColumn; | ||
| if (currentPanel) { | ||
|
Chzxxuanzheng marked this conversation as resolved.
|
||
| if (repoPath) { | ||
| gitClient.setRepo(repoPath); | ||
| extensionState.setLastActiveRepo(repoPath); | ||
| if (currentBridge) { | ||
| currentBridge.post({ | ||
| command: "loadRepos", | ||
| repos: repos, | ||
| lastActiveRepo: repoPath | ||
| }); | ||
| } | ||
| } | ||
| currentPanel.reveal(column); | ||
| return; | ||
| } | ||
|
|
@@ -61,6 +87,7 @@ export function activate(context: vscode.ExtensionContext) { | |
| if (panel.visible) bridge.post({ command: "refresh" }); | ||
| }); | ||
| bridge = webviewBridgeFactory(panel.webview, repoFileWatcher); | ||
| currentBridge = bridge; | ||
| avatarManager.registerBridge(bridge.post.bind(bridge)); | ||
| const { onPanelShown } = registerMessageHandlers(bridge, { | ||
| config, | ||
|
|
@@ -81,8 +108,10 @@ export function activate(context: vscode.ExtensionContext) { | |
| repoManager, | ||
| onDispose: () => { | ||
| currentPanel = undefined; | ||
| currentBridge = undefined; | ||
| }, | ||
| onPanelShown | ||
| onPanelShown, | ||
| initialRepo: repoPath | ||
| }); | ||
| }), | ||
| vscode.commands.registerCommand("neo-git-graph.clearAvatarCache", () => { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.