patch 9.1.0748: :keep* commmands are sometimes misidentified as :k

Problem:  The :keep{alt,jumps,marks,patterns} commmands are sometimes
          misidentified as :k.
Solution: Make sure one_letter_cmd() only returns true for :k and not
          other :keep* commands (Doug Kearns).

This currently manifests as missing completion for :keep* commands and
incorrect results from fullcommand().

E.g., fullcommand("keepmarks") returns "k" rather than "keepmarks".

The correct command, however, is executed as command modifiers are
handled specially in do_one_cmd() rather than using find_ex_command().

Fix exists(':k') so that it returns 2 for a full match.

closes: #15742

Signed-off-by: Doug Kearns <dougkearns@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_cmdmods.vim b/src/testdir/test_cmdmods.vim
index 66ff6a1..a9117e1 100644
--- a/src/testdir/test_cmdmods.vim
+++ b/src/testdir/test_cmdmods.vim
@@ -40,6 +40,44 @@
   bwipe!
 enddef
 
+def Test_keep_cmdmods_names()
+  # :k only available in legacy script
+  legacy call assert_equal('k', fullcommand(':k'))
+  legacy call assert_equal('k', fullcommand(':ke'))
+  # single character commands not supported in Vim9
+  assert_equal('', fullcommand(':k'))
+  assert_equal('keepmarks', fullcommand(':ke'))
+  assert_equal('keepmarks', fullcommand(':kee'))
+  assert_equal('keepmarks', fullcommand(':keep'))
+  assert_equal('keepmarks', fullcommand(':keepm'))
+  assert_equal('keepmarks', fullcommand(':keepma'))
+  assert_equal('keepmarks', fullcommand(':keepmar'))
+  assert_equal('keepmarks', fullcommand(':keepmark'))
+  assert_equal('keepmarks', fullcommand(':keepmarks'))
+  assert_equal('keepalt', fullcommand(':keepa'))
+  assert_equal('keepalt', fullcommand(':keepal'))
+  assert_equal('keepalt', fullcommand(':keepalt'))
+  assert_equal('keepjumps', fullcommand(':keepj'))
+  assert_equal('keepjumps', fullcommand(':keepju'))
+  assert_equal('keepjumps', fullcommand(':keepjum'))
+  assert_equal('keepjumps', fullcommand(':keepjump'))
+  assert_equal('keepjumps', fullcommand(':keepjumps'))
+  assert_equal('keeppatterns', fullcommand(':keepp'))
+  assert_equal('keeppatterns', fullcommand(':keeppa'))
+  assert_equal('keeppatterns', fullcommand(':keeppat'))
+  assert_equal('keeppatterns', fullcommand(':keeppatt'))
+  assert_equal('keeppatterns', fullcommand(':keeppatte'))
+  assert_equal('keeppatterns', fullcommand(':keeppatter'))
+  assert_equal('keeppatterns', fullcommand(':keeppattern'))
+  assert_equal('keeppatterns', fullcommand(':keeppatterns'))
+enddef
+
+def Test_cmdmod_completion()
+  assert_equal('edit', getcompletion('keepalt ed',      'cmdline')[0])
+  assert_equal('edit', getcompletion('keepjumps ed',    'cmdline')[0])
+  assert_equal('edit', getcompletion('keepmarks ed',    'cmdline')[0])
+  assert_equal('edit', getcompletion('keeppatterns ed', 'cmdline')[0])
+enddef
 
 " vim: shiftwidth=2 sts=2 expandtab