Support incrementing/decrementing the number below the cursor

Vim supports incrementing & decrementing the number below the cursor (or
after it) via Ctrl-a and Ctrl-x, respectively. Given fish's Vi mode
support, it makes sense to provide similar functionality when working on
the command line, to provide a more natural environment for Vim users.
With this change we add the necessary functionality.

Closes: #8320
Closes #11570
This commit is contained in:
Daniel Müller
2022-01-08 17:02:56 -08:00
committed by Johannes Altmanninger
parent b5bb50d742
commit 5b39efc96d
10 changed files with 220 additions and 0 deletions

115
tests/checks/vi.fish Normal file
View File

@@ -0,0 +1,115 @@
# RUN: %fish --interactive %s
fish_vi_key_bindings
commandline '1'; commandline --cursor 0; fish_vi_dec
commandline --current-buffer
# CHECK: 0
commandline '0'; commandline --cursor 0; fish_vi_dec
commandline --current-buffer
# CHECK: -1
commandline -- '-1'; commandline --cursor 0; fish_vi_dec
commandline --current-buffer
# CHECK: -2
commandline -- '-1'; commandline --cursor 0; fish_vi_inc
commandline --current-buffer
# CHECK: 0
commandline '0'; commandline --cursor 0; fish_vi_inc
commandline --current-buffer
# CHECK: 1
commandline '123'; commandline --cursor 0; fish_vi_inc
commandline --current-buffer
# CHECK: 124
commandline '123'; commandline --cursor 0; fish_vi_dec
commandline --current-buffer
# CHECK: 122
commandline '123'; commandline --cursor 1; fish_vi_inc
commandline --current-buffer
# CHECK: 124
commandline '123'; commandline --cursor 1; fish_vi_dec
commandline --current-buffer
# CHECK: 122
commandline '123'; commandline --cursor 2; fish_vi_inc
commandline --current-buffer
# CHECK: 124
commandline '123'; commandline --cursor 2; fish_vi_dec
commandline --current-buffer
# CHECK: 122
commandline 'abc123'; commandline --cursor 1; fish_vi_inc
commandline --current-buffer
# CHECK: abc124
commandline 'abc123'; commandline --cursor 1; fish_vi_dec
commandline --current-buffer
# CHECK: abc122
commandline 'abc123def'; commandline --cursor 1; fish_vi_inc
commandline --current-buffer
# CHECK: abc124def
commandline 'abc123def'; commandline --cursor 1; fish_vi_dec
commandline --current-buffer
# CHECK: abc122def
commandline 'abc123def'; commandline --cursor 5; fish_vi_inc
commandline --current-buffer
# CHECK: abc124def
commandline 'abc123def'; commandline --cursor 5; fish_vi_dec
commandline --current-buffer
# CHECK: abc122def
commandline 'abc123def'; commandline --cursor 6; fish_vi_inc
commandline --current-buffer
# CHECK: abc123def
commandline 'abc123def'; commandline --cursor 6; fish_vi_dec
commandline --current-buffer
# CHECK: abc123def
commandline 'abc99def'; commandline --cursor 1; fish_vi_inc
commandline --current-buffer
# CHECK: abc100def
commandline 'abc99def'; commandline --cursor 1; fish_vi_dec
commandline --current-buffer
# CHECK: abc98def
commandline 'abc-99def'; commandline --cursor 1; fish_vi_inc
commandline --current-buffer
# CHECK: abc-98def
commandline 'abc-99def'; commandline --cursor 1; fish_vi_dec
commandline --current-buffer
# CHECK: abc-100def
commandline '2022-04-09'; commandline --cursor 7; fish_vi_inc
commandline --current-buffer
# CHECK: 2022-04-08
commandline 'to 2022-04-09'; commandline --cursor 4; fish_vi_inc
commandline --current-buffer
# CHECK: to 2023-04-09
commandline 'to 2022-04-09'; commandline --cursor 4; fish_vi_dec
commandline --current-buffer
# CHECK: to 2021-04-09
commandline 'to 2022-04-09'; commandline --cursor 11; fish_vi_dec
commandline --current-buffer
# CHECK: to 2022-04-10
commandline 'to 2022-04-09'; commandline --cursor 11; fish_vi_inc
commandline --current-buffer
# CHECK: to 2022-04-08