diff --git a/.config/kak/autoload/expand.kak b/.config/kak/autoload/expand.kak index 7ac5bede..9435beee 100644 --- a/.config/kak/autoload/expand.kak +++ b/.config/kak/autoload/expand.kak @@ -1,6 +1,21 @@ provide-module expand %— - define-command expand %{ - execute-keys 'LH' + define-command expand-impl %{ + evaluate-commands -itersel %sh{ + sel="$kak_selection_desc" + left=${sel%%,*} + right=${sel##*,} + left_d=${left#*.} + right_d=${right#*.} + if [ "$left_d" -gt "$right_d" ]; then + # sel facing back + echo 'execute-keys HL' + elif [ "$left_d" -lt "$right_d" ]; then + # sel facing forward + echo 'execute-keys LH' + else + echo 'nop' #single cursor do nothing + fi + } } define-command shrink %{ execute-keys 'HL'