feat(session): impeccable pass + tasklane keyboard flow #158
@@ -80,10 +80,27 @@ function tokenize(body: string, highlightValues: Record<string, string> | undefi
|
||||
while (cursor < seg.text.length) {
|
||||
let matched: { key: string; value: string } | null = null
|
||||
for (const [key, value] of valueEntries) {
|
||||
if (seg.text.startsWith(value, cursor)) {
|
||||
matched = { key, value }
|
||||
break
|
||||
}
|
||||
if (!seg.text.startsWith(value, cursor)) continue
|
||||
// Word-boundary guard: a single-char value like "D" (drive letter)
|
||||
// would otherwise light up every capital D in identifiers like
|
||||
// `Get-ADUser`. We only require a boundary on a side of the value
|
||||
// that itself starts/ends with a word char, so values that begin or
|
||||
// end in punctuation (e.g. "D:\\Folder") still match cleanly.
|
||||
const valueStartsWithWordChar = /^\w/.test(value)
|
||||
const valueEndsWithWordChar = /\w$/.test(value)
|
||||
const before = cursor > 0 ? seg.text[cursor - 1] : undefined
|
||||
const after = cursor + value.length < seg.text.length
|
||||
? seg.text[cursor + value.length]
|
||||
: undefined
|
||||
const startBounded = !valueStartsWithWordChar
|
||||
|| before === undefined
|
||||
|| !/\w/.test(before)
|
||||
const endBounded = !valueEndsWithWordChar
|
||||
|| after === undefined
|
||||
|| !/\w/.test(after)
|
||||
if (!startBounded || !endBounded) continue
|
||||
matched = { key, value }
|
||||
break
|
||||
}
|
||||
if (matched) {
|
||||
flushPending()
|
||||
|
||||
Reference in New Issue
Block a user