File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -205,6 +205,8 @@ Notes:
205205 the lowest string distance.
206206 See | MiniCmdline.default_autocorrect_func() | for details.
207207
208+ - Word that matches some Command-line | abbreviation | is not autocorrected.
209+
208210- If current command expects only a single argument (like | :colorscheme | ), then
209211 autocorrection will happen only just before executing the command.
210212
Original file line number Diff line number Diff line change 179179--- the lowest string distance.
180180--- See |MiniCmdline.default_autocorrect_func()| for details.
181181---
182+ --- - Word that matches some Command-line |abbreviation| is not autocorrected.
183+ ---
182184--- - If current command expects only a single argument (like |:colorscheme|), then
183185--- autocorrection will happen only just before executing the command.
184186---
@@ -738,7 +740,7 @@ H.autocorrect = function(is_final)
738740 -- Compute autocorrection
739741 local state_to_use = is_final and state or state_prev
740742 local word = state_to_use .complpat
741- if word == ' ' then return end
743+ if word == ' ' or vim . fn . maparg ( word , ' c ' , true ) ~= ' ' then return end
742744
743745 local func = H .cache .config .autocorrect .func or MiniCmdline .default_autocorrect_func
744746 local new_word = func ({ word = word , type = state_to_use .compltype }) or word
Original file line number Diff line number Diff line change @@ -840,6 +840,30 @@ T['Autocorrect']['respects mappings'] = function()
840840 eq (child .fn .histget (' cmd' , - 1 ), ' echo' )
841841end
842842
843+ T [' Autocorrect' ][' respects abbreviations' ] = function ()
844+ child .lua ([[
845+ _G.log = {}
846+ local orig = MiniCmdline.default_autocorrect_func
847+ MiniCmdline.default_autocorrect_func = function(...)
848+ table.insert(_G.log, vim.deepcopy({ ... }))
849+ return orig(...)
850+ end
851+ ]] )
852+
853+ child .cmd (' cabbrev Y wincmd' )
854+ child .cmd (' cnoreabbrev <buffer> D bwipeout' )
855+
856+ type_keys (' :' , ' Y' , ' ' )
857+ validate_cmdline (' wincmd ' )
858+ type_keys (' <Esc>' )
859+
860+ type_keys (' :' , ' D' , ' <CR>' )
861+ eq (child .fn .histget (' cmd' , - 1 ), ' bwipeout' )
862+
863+ -- Should not call `config.autocorrect.func` for abbreviations
864+ eq (child .lua_get (' _G.log' ), {})
865+ end
866+
843867T [' Autocorrect' ][' can act after mappings appended text' ] = function ()
844868 -- Should act if text increases latest word
845869 child .cmd (' cnoremap <C-x> www' )
You can’t perform that action at this time.
0 commit comments