Skip to content

Commit

Permalink
🐛 Fix cursor position for multiline
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Aug 6, 2024
1 parent 4713f61 commit 5064086
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rime-ime
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ draw-ui() {
rime getCommit $1 commit
LBUFFER+=$commit[text]
fi
local -i ime_len=$(wc -L <<< $LBUFFER)
local last_line=${LBUFFER##*$'\n'}
local -i ime_len=$(wc -L <<< "$last_line")
local ime_prefix=${(l:$ime_len:: :)}
local prompt_prefix=${(l:$prompt_len:: :)}
local prompt_prefix
if [[ $last_line == $LBUFFER ]]; then
prompt_prefix=${(l:$prompt_len:: :)}
else
prompt_prefix=''
fi
local cursor_pos="$(( context_composition[cursor_pos] + 1 ))"
preedit=$context_composition[preedit]
local text="$prompt_prefix$ime_prefix$preedit[0, cursor_pos - 1]$cursor$preedit[cursor_pos,-1]"
Expand Down

0 comments on commit 5064086

Please sign in to comment.