Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions webview-ui/src/utils/context-mentions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,17 @@ export function getContextMenuOptions(
const seen = new Set()
const deduped = allItems.filter((item) => {
// Normalize paths for deduplication by ensuring leading slashes
const normalizedValue = item.value && !item.value.startsWith("/") ? `/${item.value}` : item.value
const key = `${item.type}-${normalizedValue}`
const normalizedValue = item.value
let key = ""
if (
item.type === ContextMenuOptionType.File ||
item.type === ContextMenuOptionType.Folder ||
item.type === ContextMenuOptionType.OpenedFile
) {
key = normalizedValue!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the non-null assertion (!) on normalizedValue may be risky because item.value is optional. Consider handling the undefined case explicitly.

Suggested change
key = normalizedValue!
key = normalizedValue ?? ''

} else {
key = `${item.type}-${normalizedValue}`
}
if (seen.has(key)) return false
seen.add(key)
return true
Expand Down