You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Go Prompt auto-completion uses a character index as a byte offset #264
Type the following statement and press Tab at the end of re:
YIELD "中文" AS re
Actual behavior
The completion callback passes d.CursorPositionCol() to completer.NewCompleter().
In go-prompt v0.2.6, CursorPositionCol() returns a character (rune) index. However, NewCompleter() uses this position to slice a Go string, which requires a byte offset.
When multibyte UTF-8 characters appear before the cursor, the input is truncated at the wrong position.
For example, the completion logic may use A instead of RE as the completion prefix.
Expected behavior
Tab completion should correctly identify the word immediately before the cursor, regardless of whether the input contains ASCII, Chinese, or mixed UTF-8 characters.
The completion result should be based on the RE prefix in the example above.
Proposed solution
Use the byte length of d.CurrentLineBeforeCursor() as the cursor position passed to completer.NewCompleter().
This ensures that the position matches the byte indexing used by Go string slicing.
Activity