diff --git a/src/runtime/components/navigation/CommandPaletteGroup.vue b/src/runtime/components/navigation/CommandPaletteGroup.vue
index 072675da..506e5020 100644
--- a/src/runtime/components/navigation/CommandPaletteGroup.vue
+++ b/src/runtime/components/navigation/CommandPaletteGroup.vue
@@ -28,11 +28,13 @@
- {{ command.prefix }}
+ {{ command.prefix }}
+
+ {{ command[commandAttribute] }}
+
-
- {{ command[commandAttribute] }}
- {{ command.suffix }}
+
+ {{ command.suffix }}
@@ -87,13 +89,36 @@ const label = computed(() => {
return typeof label === 'function' ? label(props.query) : label
})
-function highlight ({ indices, value }: { indices: number[][], value:string }, i = 1): string {
- const pair = indices[indices.length - i]
- if (!pair) {
- return value
+function highlight (text, { indices, value }: { indices: number[][], value:string }): string {
+ if (text === value) {
+ return ''
}
- return `${highlight({ indices, value: value.substring(0, pair[0]) }, i + 1)}${value.substring(pair[0], pair[1] + 1)}${value.substring(pair[1] + 1)}`
+ let content = ''
+ let nextUnhighlightedIndiceStartingIndex = 0
+
+ indices.forEach((indice) => {
+ const lastIndiceNextIndex = indice[1] + 1
+ const isMatched = (lastIndiceNextIndex - indice[0]) >= props.query.length
+
+ content += [
+ value.substring(nextUnhighlightedIndiceStartingIndex, indice[0]),
+ isMatched && '',
+ value.substring(indice[0], lastIndiceNextIndex),
+ isMatched && ''
+ ].filter(Boolean).join('')
+
+ nextUnhighlightedIndiceStartingIndex = lastIndiceNextIndex
+ })
+
+ content += value.substring(nextUnhighlightedIndiceStartingIndex)
+
+ const index = content.indexOf('')
+ if (index > 60) {
+ content = `...${content.substring(index - 60)}`
+ }
+
+ return content
}