Skip to content

Commit 608ba50

Browse files
committed
Avoids duplicate command creation using counter
1 parent 72a7610 commit 608ba50

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/views/nodes/common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { commands, TreeItem, TreeItemCollapsibleState } from 'vscode';
33
import { GlyphChars } from '../../constants';
44
import { unknownGitUri } from '../../git/gitUri';
55
import { configuration } from '../../system/-webview/configuration';
6+
import { getScopedCounter } from '../../system/counter';
67
import { isPromise } from '../../system/promise';
78
import type { View } from '../viewBase';
89
import type { PageableViewNode } from './abstract/viewNode';
@@ -76,6 +77,8 @@ export class CommandMessageNode extends MessageNode {
7677
}
7778
}
7879

80+
const actionCommandCounter = getScopedCounter();
81+
7982
export class ActionMessageNode extends CommandMessageNode {
8083
private readonly _disposable: Disposable;
8184

@@ -90,7 +93,7 @@ export class ActionMessageNode extends CommandMessageNode {
9093
contextValue?: string,
9194
resourceUri?: Uri,
9295
) {
93-
const command = { command: `gitlens.node.action:${Date.now()}`, title: 'Execute action' };
96+
const command = { command: `gitlens.node.action:${actionCommandCounter.next()}`, title: 'Execute action' };
9497
super(view, parent, command, message, description, tooltip, iconPath, contextValue, resourceUri);
9598

9699
this._disposable = commands.registerCommand(command.command, action.bind(undefined, this));

0 commit comments

Comments
 (0)