Skip to content

Commit 88a7ce3

Browse files
authored
[ES|QL] Ignore trailing whitespace in overlap matching (elastic#258806)
## Summary This is the first of two fixes. I'm separating them because they're two different scopes (and perhaps the second is optional). That's happens for example when you write event or event.dataset then press `space `and then `backspace` and/or continue typing `backespace` Before . <img width="933" height="215" alt="before (1)" src="https://github.com/user-attachments/assets/f3db3cb9-cbb6-4646-a224-5a1f90a55583" /> after <img width="929" height="140" alt="after" src="https://github.com/user-attachments/assets/e4135f73-018e-4630-87d2-7399c2f888e7" />
1 parent d0b75a5 commit 88a7ce3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • src/platform/packages/shared/kbn-esql-language/src/language/autocomplete/utils

src/platform/packages/shared/kbn-esql-language/src/language/autocomplete/utils/prefix_range.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ export function attachReplacementRanges(
106106
return [resolvedSuggestion];
107107
}
108108

109-
const overlapRange = CONTAINS_WHITESPACE_REGEX.test(suggestion.text)
109+
// getOverlapRange is only needed for suggestions whose internal whitespace is
110+
// part of the typed sequence, such as "IS NOT NULL" after "IS NO|". Using
111+
// trimEnd() keeps trailing formatting whitespace from routing otherwise-normal
112+
// suggestions through the overlap path.
113+
const overlapRange = CONTAINS_WHITESPACE_REGEX.test(suggestion.text.trimEnd())
110114
? getOverlapRange(innerText, suggestion.text)
111115
: undefined;
112116
const effectiveRange = overlapRange ?? { start: range.start, end: range.end };

0 commit comments

Comments
 (0)