mirror of
https://github.com/zsh-users/zsh-autosuggestions.git
synced 2025-04-17 11:35:31 +08:00
Simplified the accept-line call. Still doing a stack overflow
This commit is contained in:
parent
d4c6aab96c
commit
daaedc8e3d
@ -109,6 +109,7 @@ _zsh_autosuggest_invoke_original_widget() {
|
|||||||
[ $# -gt 0 ] || return
|
[ $# -gt 0 ] || return
|
||||||
|
|
||||||
local original_widget_name="$1"
|
local original_widget_name="$1"
|
||||||
|
print $original_widget_name
|
||||||
|
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
@ -113,30 +113,67 @@ _zsh_autosuggest_suggest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Accept the entire suggestion
|
# Accept the entire suggestion
|
||||||
|
# _zsh_autosuggest_accept() {
|
||||||
|
# local -i max_cursor_pos=$#BUFFER
|
||||||
|
#
|
||||||
|
# # When vicmd keymap is active, the cursor can't move all the way
|
||||||
|
# # to the end of the buffer
|
||||||
|
# if [ "$KEYMAP" = "vicmd" ]; then
|
||||||
|
# max_cursor_pos=$((max_cursor_pos - 1))
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Only accept if the cursor is at the end of the buffer
|
||||||
|
# if [ $CURSOR -eq $max_cursor_pos ]; then
|
||||||
|
# # Add the suggestion to the buffer
|
||||||
|
# BUFFER="$BUFFER$POSTDISPLAY"
|
||||||
|
#
|
||||||
|
# # Remove the suggestion
|
||||||
|
# unset POSTDISPLAY
|
||||||
|
#
|
||||||
|
# # Move the cursor to the end of the buffer
|
||||||
|
# CURSOR=${#BUFFER}
|
||||||
|
#
|
||||||
|
# print "a"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget "end-of-line"
|
||||||
|
# print "b"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# print "1"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget $@
|
||||||
|
# print "2"
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# # When vicmd keymap is active, the cursor can't move all the way
|
||||||
|
# # to the end of the buffer
|
||||||
|
# if [ "$KEYMAP" = "vicmd" ]; then
|
||||||
|
# max_cursor_pos=$((max_cursor_pos - 1))
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Only accept if the cursor is at the end of the buffer
|
||||||
|
# if [ $CURSOR -eq $max_cursor_pos ]; then
|
||||||
|
# # Add the suggestion to the buffer
|
||||||
|
# BUFFER="$BUFFER$POSTDISPLAY"
|
||||||
|
#
|
||||||
|
# # Remove the suggestion
|
||||||
|
# unset POSTDISPLAY
|
||||||
|
#
|
||||||
|
# # Move the cursor to the end of the buffer
|
||||||
|
# CURSOR=${#BUFFER}
|
||||||
|
#
|
||||||
|
# print "a"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget "end-of-line"
|
||||||
|
# print "b"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# print "1"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget $@
|
||||||
|
# print "2"
|
||||||
|
# }
|
||||||
_zsh_autosuggest_accept() {
|
_zsh_autosuggest_accept() {
|
||||||
local -i max_cursor_pos=$#BUFFER
|
# Accepting the whole line is basically a specific case of
|
||||||
|
# accepting partially with "end-of-line" widget
|
||||||
# When vicmd keymap is active, the cursor can't move all the way
|
# _zsh_autosuggest_partial_accept ".end-of-line"
|
||||||
# to the end of the buffer
|
_zsh_autosuggest_partial_accept "end-of-line"
|
||||||
if [ "$KEYMAP" = "vicmd" ]; then
|
|
||||||
max_cursor_pos=$((max_cursor_pos - 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only accept if the cursor is at the end of the buffer
|
|
||||||
if [ $CURSOR -eq $max_cursor_pos ]; then
|
|
||||||
# Add the suggestion to the buffer
|
|
||||||
BUFFER="$BUFFER$POSTDISPLAY"
|
|
||||||
|
|
||||||
# Remove the suggestion
|
|
||||||
unset POSTDISPLAY
|
|
||||||
|
|
||||||
# Move the cursor to the end of the buffer
|
|
||||||
CURSOR=${#BUFFER}
|
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget end-of-line
|
|
||||||
fi
|
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Accept the entire suggestion and execute it
|
# Accept the entire suggestion and execute it
|
||||||
|
@ -230,6 +230,7 @@ _zsh_autosuggest_invoke_original_widget() {
|
|||||||
[ $# -gt 0 ] || return
|
[ $# -gt 0 ] || return
|
||||||
|
|
||||||
local original_widget_name="$1"
|
local original_widget_name="$1"
|
||||||
|
print $original_widget_name
|
||||||
|
|
||||||
shift
|
shift
|
||||||
|
|
||||||
@ -378,30 +379,67 @@ _zsh_autosuggest_suggest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Accept the entire suggestion
|
# Accept the entire suggestion
|
||||||
|
# _zsh_autosuggest_accept() {
|
||||||
|
# local -i max_cursor_pos=$#BUFFER
|
||||||
|
#
|
||||||
|
# # When vicmd keymap is active, the cursor can't move all the way
|
||||||
|
# # to the end of the buffer
|
||||||
|
# if [ "$KEYMAP" = "vicmd" ]; then
|
||||||
|
# max_cursor_pos=$((max_cursor_pos - 1))
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Only accept if the cursor is at the end of the buffer
|
||||||
|
# if [ $CURSOR -eq $max_cursor_pos ]; then
|
||||||
|
# # Add the suggestion to the buffer
|
||||||
|
# BUFFER="$BUFFER$POSTDISPLAY"
|
||||||
|
#
|
||||||
|
# # Remove the suggestion
|
||||||
|
# unset POSTDISPLAY
|
||||||
|
#
|
||||||
|
# # Move the cursor to the end of the buffer
|
||||||
|
# CURSOR=${#BUFFER}
|
||||||
|
#
|
||||||
|
# print "a"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget "end-of-line"
|
||||||
|
# print "b"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# print "1"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget $@
|
||||||
|
# print "2"
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# # When vicmd keymap is active, the cursor can't move all the way
|
||||||
|
# # to the end of the buffer
|
||||||
|
# if [ "$KEYMAP" = "vicmd" ]; then
|
||||||
|
# max_cursor_pos=$((max_cursor_pos - 1))
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# # Only accept if the cursor is at the end of the buffer
|
||||||
|
# if [ $CURSOR -eq $max_cursor_pos ]; then
|
||||||
|
# # Add the suggestion to the buffer
|
||||||
|
# BUFFER="$BUFFER$POSTDISPLAY"
|
||||||
|
#
|
||||||
|
# # Remove the suggestion
|
||||||
|
# unset POSTDISPLAY
|
||||||
|
#
|
||||||
|
# # Move the cursor to the end of the buffer
|
||||||
|
# CURSOR=${#BUFFER}
|
||||||
|
#
|
||||||
|
# print "a"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget "end-of-line"
|
||||||
|
# print "b"
|
||||||
|
# fi
|
||||||
|
#
|
||||||
|
# print "1"
|
||||||
|
# _zsh_autosuggest_invoke_original_widget $@
|
||||||
|
# print "2"
|
||||||
|
# }
|
||||||
_zsh_autosuggest_accept() {
|
_zsh_autosuggest_accept() {
|
||||||
local -i max_cursor_pos=$#BUFFER
|
# Accepting the whole line is basically a specific case of
|
||||||
|
# accepting partially with "end-of-line" widget
|
||||||
# When vicmd keymap is active, the cursor can't move all the way
|
# _zsh_autosuggest_partial_accept ".end-of-line"
|
||||||
# to the end of the buffer
|
_zsh_autosuggest_partial_accept "end-of-line"
|
||||||
if [ "$KEYMAP" = "vicmd" ]; then
|
|
||||||
max_cursor_pos=$((max_cursor_pos - 1))
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Only accept if the cursor is at the end of the buffer
|
|
||||||
if [ $CURSOR -eq $max_cursor_pos ]; then
|
|
||||||
# Add the suggestion to the buffer
|
|
||||||
BUFFER="$BUFFER$POSTDISPLAY"
|
|
||||||
|
|
||||||
# Remove the suggestion
|
|
||||||
unset POSTDISPLAY
|
|
||||||
|
|
||||||
# Move the cursor to the end of the buffer
|
|
||||||
CURSOR=${#BUFFER}
|
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget end-of-line
|
|
||||||
fi
|
|
||||||
|
|
||||||
_zsh_autosuggest_invoke_original_widget $@
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Accept the entire suggestion and execute it
|
# Accept the entire suggestion and execute it
|
||||||
|
Loading…
Reference in New Issue
Block a user