Skip to content

Commit 5828a6c

Browse files
committed
Differentiate checkpoint quick pick items by adding numerical counts to duplicate descriptions
1 parent fdaa125 commit 5828a6c

1 file changed

Lines changed: 46 additions & 21 deletions

File tree

‎packages/vscode/src/commands/checkpoints-command/checkpoints-command.ts‎

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,18 @@ export const checkpoints_command = (
100100
}
101101

102102
const visible_checkpoints = checkpoints.filter((c) => !c.is_temporary)
103+
const detail_counts = new Map<string, number>()
104+
for (const c of visible_checkpoints) {
105+
if (c.description) {
106+
detail_counts.set(
107+
c.description,
108+
(detail_counts.get(c.description) || 0) + 1
109+
)
110+
}
111+
}
112+
113+
const current_detail_counts = new Map(detail_counts)
114+
103115
quick_pick.items = [
104116
{
105117
id: 'add-new',
@@ -115,27 +127,40 @@ export const checkpoints_command = (
115127
}
116128
]
117129
: []),
118-
...visible_checkpoints.map((c, index) => ({
119-
id: c.timestamp.toString(),
120-
label: c.title,
121-
description: dayjs(c.timestamp).fromNow(),
122-
detail: c.description,
123-
checkpoint: c,
124-
index,
125-
buttons:
126-
c.title == 'Created by user'
127-
? [
128-
{
129-
iconPath: new vscode.ThemeIcon('edit'),
130-
tooltip: 'Edit Description'
131-
},
132-
{
133-
iconPath: new vscode.ThemeIcon('trash'),
134-
tooltip: 'Delete'
135-
}
136-
]
137-
: undefined
138-
}))
130+
...visible_checkpoints.map((c, index) => {
131+
let detail = c.description
132+
if (
133+
c.description &&
134+
(detail_counts.get(c.description) ?? 0) > 1
135+
) {
136+
const current_count = current_detail_counts.get(c.description)!
137+
current_detail_counts.set(c.description, current_count - 1)
138+
if (current_count > 1) {
139+
detail = `(${current_count - 1}) ${c.description}`
140+
}
141+
}
142+
return {
143+
id: c.timestamp.toString(),
144+
label: c.title,
145+
description: dayjs(c.timestamp).fromNow(),
146+
detail,
147+
checkpoint: c,
148+
index,
149+
buttons:
150+
c.title == 'Created by user'
151+
? [
152+
{
153+
iconPath: new vscode.ThemeIcon('edit'),
154+
tooltip: 'Edit Description'
155+
},
156+
{
157+
iconPath: new vscode.ThemeIcon('trash'),
158+
tooltip: 'Delete'
159+
}
160+
]
161+
: undefined
162+
}
163+
})
139164
]
140165
quick_pick.busy = false
141166
}

0 commit comments

Comments
 (0)