mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2024-11-18 09:51:06 +01:00
Put the modifications in the source, and removed debugging instructions
This commit is contained in:
parent
bf95b4c093
commit
603132c6b8
2 changed files with 16 additions and 13 deletions
|
@ -164,6 +164,13 @@ _zsh_autosuggest_partial_accept() {
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
_zsh_autosuggest_invoke_original_widget $@
|
||||||
retval=$?
|
retval=$?
|
||||||
|
|
||||||
|
# In vicmd keymap, the cursor is placed on the current character
|
||||||
|
# instead of after it. We increment it by 1 to keep the following logic
|
||||||
|
# working even in thi case.
|
||||||
|
if [ $KEYMAP = 'vicmd' ]; then
|
||||||
|
(( CURSOR++ ))
|
||||||
|
fi
|
||||||
|
|
||||||
# If we've moved past the end of the original buffer
|
# If we've moved past the end of the original buffer
|
||||||
if (( $CURSOR > $#original_buffer )); then
|
if (( $CURSOR > $#original_buffer )); then
|
||||||
# Set POSTDISPLAY to text right of the cursor
|
# Set POSTDISPLAY to text right of the cursor
|
||||||
|
@ -176,6 +183,11 @@ _zsh_autosuggest_partial_accept() {
|
||||||
BUFFER="$original_buffer"
|
BUFFER="$original_buffer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore CURSOR
|
||||||
|
if [ $KEYMAP = 'vicmd' ]; then
|
||||||
|
(( CURSOR-- ))
|
||||||
|
fi
|
||||||
|
|
||||||
return $retval
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -438,26 +438,17 @@ _zsh_autosuggest_partial_accept() {
|
||||||
# Temporarily accept the suggestion.
|
# Temporarily accept the suggestion.
|
||||||
BUFFER="$BUFFER$POSTDISPLAY"
|
BUFFER="$BUFFER$POSTDISPLAY"
|
||||||
|
|
||||||
print keymap: $KEYMAP >> /tmp/zsh_autosuggest_log
|
|
||||||
print original widget name: $@ >> /tmp/zsh_autosuggest_log
|
|
||||||
print original buffer: $original_buffer >> /tmp/zsh_autosuggest_log
|
|
||||||
print original postdisplay: $POSTDISPLAY >> /tmp/zsh_autosuggest_log
|
|
||||||
print original cursor: $CURSOR >> /tmp/zsh_autosuggest_log
|
|
||||||
|
|
||||||
# Original widget moves the cursor
|
# Original widget moves the cursor
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
_zsh_autosuggest_invoke_original_widget $@
|
||||||
retval=$?
|
retval=$?
|
||||||
|
|
||||||
# In vicmd keymap, the cursor is placed on the last character, not after
|
# In vicmd keymap, the cursor is placed on the current character
|
||||||
# For this reason, we need to increment it by 1 for our tests on it to
|
# instead of after it. We increment it by 1 to keep the following logic
|
||||||
# keep working, then roll it back to its initial value
|
# working even in thi case.
|
||||||
if [ $KEYMAP = 'vicmd' ]; then
|
if [ $KEYMAP = 'vicmd' ]; then
|
||||||
(( CURSOR++ ))
|
(( CURSOR++ ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print retval: $retval >> /tmp/zsh_autosuggest_log
|
|
||||||
print final cursor: $CURSOR >> /tmp/zsh_autosuggest_log
|
|
||||||
|
|
||||||
# If we've moved past the end of the original buffer
|
# If we've moved past the end of the original buffer
|
||||||
if (( $CURSOR > $#original_buffer )); then
|
if (( $CURSOR > $#original_buffer )); then
|
||||||
# Set POSTDISPLAY to text right of the cursor
|
# Set POSTDISPLAY to text right of the cursor
|
||||||
|
@ -470,11 +461,11 @@ _zsh_autosuggest_partial_accept() {
|
||||||
BUFFER="$original_buffer"
|
BUFFER="$original_buffer"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Restore CURSOR
|
||||||
if [ $KEYMAP = 'vicmd' ]; then
|
if [ $KEYMAP = 'vicmd' ]; then
|
||||||
(( CURSOR-- ))
|
(( CURSOR-- ))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
print '' >> /tmp/zsh_autosuggest_log
|
|
||||||
return $retval
|
return $retval
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue