From 1e4934989b77463d89883d7259bf693d23d7b328 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 29 Aug 2024 14:15:48 +0200 Subject: [PATCH] tmux:textobjs: Do nothing when sitting on a space When the cursor sits on a space character on `iw`, vim does nothing. --- .config/tmux/textobjs.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.config/tmux/textobjs.sh b/.config/tmux/textobjs.sh index 30209f0..4488551 100755 --- a/.config/tmux/textobjs.sh +++ b/.config/tmux/textobjs.sh @@ -31,6 +31,12 @@ case "$motion" in copy_x="$(get_var copy_cursor_x)" : "$((copy_x += 1))" copy_line="$(get_var copy_cursor_line)" + + # Do nothing if the cursor sits on a space + # TODO: Do the same for other non-word characters + char_curr="$(printf %s "$copy_line" | cut -c$((copy_x + 1)))" + [ "$char_curr" != " " ] || return 0 + copy_line_post="$(printf %s "$copy_line" | cut -c"${copy_x}"-)" copy_line_pre="$(printf %s "$copy_line" | cut -c-"${copy_x}")" copy_word="$(get_var copy_cursor_word)" @@ -52,6 +58,10 @@ case "$motion" in copy_x="$(get_var copy_cursor_x)" copy_line="$(get_var copy_cursor_line)" + # Do nothing if the cursor sits on the space + char_curr="$(printf %s "$copy_line" | cut -c$((copy_x + 1)))" + [ "$char_curr" != " " ] || return 0 + # NOTE: cut will print an error on index 0 char_pre="$(printf %s "$copy_line" | cut -c"$copy_x" 2>/dev/null)" char_post="$(printf %s "$copy_line" | cut -c$((copy_x + 2)))"