*ctx*: Correct handling of the list boundaries

This commit is contained in:
Sebastian Gniazdowski 2019-07-07 10:53:28 +02:00
parent 7997c62697
commit ab2cb3444b
2 changed files with 5 additions and 3 deletions

View file

@ -39,7 +39,7 @@ typeset -gi __hsmw_page_start_idx __hsmw_prev_offset __hsmw_recedit_trap_execute
typeset -ga __hsmw_hcw_found
# Context variables
typeset -gi __hsmw_ctx __hsmw_ctx_idx __hsmw_ctx_text_idx __hsmw_ctx_which
typeset -gi __hsmw_ctx __hsmw_ctx_idx __hsmw_ctx_prev_idx __hsmw_ctx_text_idx __hsmw_ctx_which
typeset -gi __hsmw_ctx_page_start_idx __hsmw_ctx_prev_offset
typeset -g __hsmw_ctx_to_search
typeset -ga __hsmw_ctx_disp_list

View file

@ -1,6 +1,8 @@
# -*- Mode: sh; sh-indentation: 4; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# vim:ft=zsh:sw=4:sts=4:et
__hsmw_ctx_prev_idx="$__hsmw_ctx_idx"
[[ "$WIDGET" = *-word ]] && (( __hsmw_ctx_idx -- ))
[[ "$WIDGET" = *-backwards ]] && (( __hsmw_ctx_idx ++ ))
[[ "$WIDGET" = *-pforwards ]] && (( __hsmw_ctx_idx = __hsmw_ctx_idx - __hsmw_page_size ))
@ -91,8 +93,8 @@ _hsmw_ctx_main() {
integer page_size="$__hsmw_page_size"
[[ "$page_size" -gt "$max_index" ]] && page_size="$max_index"
[[ "$the_index" -le 0 ]] && the_index="$max_index"
[[ "$the_index" -gt "$max_index" ]] && the_index=1
[[ "$the_index" -le 0 ]] && { __hsmw_ctx_idx="$__hsmw_ctx_prev_idx"; the_index=1; }
[[ "$the_index" -gt "$(( max_index - 1))" ]] && { __hsmw_ctx_idx="$__hsmw_ctx_prev_idx"; the_index="$(( max_index - 1 ))"; }
integer page_start_idx=$(( ((the_index-1)/page_size)*page_size+1 ))
integer on_page_idx=$(( page_size - (the_index - page_start_idx) ))