From 05db1e86970e48986f941ea252079768f44916b9 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Fri, 15 May 2020 18:37:03 +0300 Subject: [PATCH] rc spell: Make `:spell-next` wrap around the buffer --- rc/tools/spell.kak | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rc/tools/spell.kak b/rc/tools/spell.kak index 0217c51e..8db40e72 100644 --- a/rc/tools/spell.kak +++ b/rc/tools/spell.kak @@ -101,7 +101,8 @@ define-command spell-next %{ evaluate-commands %sh{ exit fi - printf %s "${kak_opt_spell_regions#* }" | awk -v anchor_line="${anchor_line}" \ + printf %s "${kak_opt_spell_regions#* }" | awk -v start_first="${start_first}" \ + -v anchor_line="${anchor_line}" \ -v anchor_col="${anchor_col}" ' BEGIN { anchor_line = int(anchor_line) @@ -126,9 +127,16 @@ define-command spell-next %{ evaluate-commands %sh{ || (start_line == anchor_line && start_col <= anchor_col)) continue - printf "select %s\n", sel + target_sel = sel break } + } + + END { + if (!target_sel) + target_sel = start_first + + printf "select %s\n", target_sel }' } }