mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 12:21:13 -05:00
Fix url menu showing
This commit is contained in:
@@ -109,18 +109,27 @@ const ChatTextArea = forwardRef<HTMLTextAreaElement, ChatTextAreaProps>(
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
setSelectedMenuIndex((prevIndex) => {
|
setSelectedMenuIndex((prevIndex) => {
|
||||||
const direction = event.key === "ArrowUp" ? -1 : 1
|
const direction = event.key === "ArrowUp" ? -1 : 1
|
||||||
let newIndex = prevIndex + direction
|
|
||||||
const options = getContextMenuOptions(searchQuery, selectedType)
|
const options = getContextMenuOptions(searchQuery, selectedType)
|
||||||
const optionsLength = options.length
|
const optionsLength = options.length
|
||||||
|
|
||||||
if (newIndex < 0) newIndex = optionsLength - 1
|
if (optionsLength === 0) return prevIndex
|
||||||
if (newIndex >= optionsLength) newIndex = 0
|
|
||||||
|
|
||||||
while (options[newIndex]?.type === "url") {
|
// Find selectable options (non-URL types)
|
||||||
newIndex = (newIndex + direction + optionsLength) % optionsLength
|
const selectableOptions = options.filter((option) => option.type !== "url")
|
||||||
}
|
|
||||||
|
|
||||||
return newIndex
|
if (selectableOptions.length === 0) return -1 // No selectable options
|
||||||
|
|
||||||
|
// Find the index of the next selectable option
|
||||||
|
const currentSelectableIndex = selectableOptions.findIndex(
|
||||||
|
(option) => option === options[prevIndex]
|
||||||
|
)
|
||||||
|
|
||||||
|
const newSelectableIndex =
|
||||||
|
(currentSelectableIndex + direction + selectableOptions.length) %
|
||||||
|
selectableOptions.length
|
||||||
|
|
||||||
|
// Find the index of the selected option in the original options array
|
||||||
|
return options.findIndex((option) => option === selectableOptions[newSelectableIndex])
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,9 @@ export function shouldShowContextMenu(text: string, position: number): boolean {
|
|||||||
// Check if there's any whitespace after the '@'
|
// Check if there's any whitespace after the '@'
|
||||||
if (/\s/.test(textAfterAt)) return false
|
if (/\s/.test(textAfterAt)) return false
|
||||||
|
|
||||||
// Show the menu if there's just '@' or '@' followed by some text
|
// Don't show the menu if it's a URL
|
||||||
|
if (textAfterAt.toLowerCase().startsWith("http")) return false
|
||||||
|
|
||||||
|
// Show the menu if there's just '@' or '@' followed by some text (but not a URL)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user