diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt index 3d367bcd78..2c01c65316 100644 --- a/runtime/doc/terminal.txt +++ b/runtime/doc/terminal.txt @@ -1367,7 +1367,7 @@ Four autocommands can be used: > *TermdebugStartPre* TermdebugStartPre Before starting debugging. Not triggered if the debugger is already - running or |g:termdebugger| cannot be + running or the debugger command cannot be executed. *TermdebugStartPost* TermdebugStartPost After debugging has initialized. @@ -1398,18 +1398,24 @@ in a buffer with 'buftype' set to "prompt". This works slightly differently: *termdebug_use_prompt* Prompt mode can be used even when the |+terminal| feature is present with: > + let g:termdebug_config['use_prompt'] = 1 +Or if there is no g:termdebug_config: > let g:termdebug_use_prompt = 1 < *termdebug_map_K* The K key is normally mapped to :Evaluate. If you do not want this use: > + let g:termdebug_config['map_K'] = 0 +Or if there is no g:termdebug_config: > let g:termdebug_map_K = 0 - < *termdebug_disasm_window* -If you want the Asm window shown by default, set this to 1. Setting to -any value greater than 1 will set the Asm window height to that value: > +If you want the Asm window shown by default, set the flag to 1. +the "disasm_window_height" entry can be used to set the window height: > + let g:termdebug_config['disasm_window'] = 1 + let g:termdebug_config['disasm_window_height'] = 15 +or, if there is no g:termdebug_config: > let g:termdebug_disasm_window = 15 -< +Any value greater than 1 will set the Asm window height to that value: > Communication ~ *termdebug-communication* @@ -1426,15 +1432,36 @@ communication channel. Customizing ~ + *termdebug-customizing* *g:termdebug_config* +In the past several global variables were used for configuration. These are +deprecated, using the g:termdebug_config dictionary is preferred. When +g:termdebug_config exists the other global variables will not be used. -GDB command *termdebug-customizing* + +GDB command ~ *g:termdebugger* -To change the name of the gdb command, set the "g:termdebugger" variable before -invoking `:Termdebug`: > +To change the name of the gdb command, set "debugger" entry in +g:termdebug_config or the "g:termdebugger" variable before invoking +`:Termdebug`: > + let g:termdebug_config['command'] = "mygdb" +Or if there is no g:termdebug_config: > let g:termdebugger = "mygdb" + If the command needs an argument use a List: > + let g:termdebug_config['command'] = ['rr', 'replay', '--'] +Or if there is no g:termdebug_config: > let g:termdebugger = ['rr', 'replay', '--'] -< *gdb-version* + +Several arguments will be added to make gdb work well for the debugger. +If you want to modify them, add a function to filter the argument list: > + let g:termdebug_config['command_filter'] = MyDebugFilter + +If you do not want the arguments to be added, but you do need to set the +"pty", use a function to add the necessary arguments: > + let g:termdebug_config['command_add_args'] = MyAddArguments +The function will be called with the list of arguments so far, and a second +argument that is the name of the pty. + *gdb-version* Only debuggers fully compatible with gdb will work. Vim uses the GDB/MI interface. The "new-ui" command requires gdb version 7.12 or later. if you get this error: @@ -1442,8 +1469,8 @@ get this error: Then your gdb is too old. -Colors *hl-debugPC* *hl-debugBreakpoint* - +Colors~ + *hl-debugPC* *hl-debugBreakpoint* The color of the signs can be adjusted with these highlight groups: - debugPC the current position - debugBreakpoint a breakpoint @@ -1473,6 +1500,8 @@ these entries to the popup menu: Clear breakpoint `:Clear` Evaluate `:Evaluate` If you don't want this then disable it with: > + let g:termdebug_config['popup'] = 0 +or if there is no g:termdebug_config: > let g:termdebug_popup = 0 @@ -1480,15 +1509,17 @@ Vim window width *termdebug_wide* To change the width of the Vim window when debugging starts and use a vertical split: > + let g:termdebug_config['wide'] = 163 +Or if there is no g:termdebug_config: > let g:termdebug_wide = 163 This will set 'columns' to 163 when `:Termdebug` is used. The value is restored when quitting the debugger. -If g:termdebug_wide is set and 'columns' is already a greater value, then a +If the wide value is set and 'columns' is already a greater value, then a vertical split will be used without modifying 'columns'. -Set g:termdebug_wide to 1 to use a vertical split without ever changing +Set the wide value to 1 to use a vertical split without ever changing 'columns'. This is useful when the terminal can't be resized by Vim. diff --git a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim index a5aa5a7ad9..a9acbb2717 100644 --- a/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim +++ b/runtime/pack/dist/opt/termdebug/plugin/termdebug.vim @@ -2,7 +2,7 @@ " " Author: Bram Moolenaar " Copyright: Vim license applies, see ":help license" -" Last Change: 2022 May 09 +" Last Change: 2022 May 23 " " WORK IN PROGRESS - The basics works stable, more to come " Note: In general you need at least GDB 7.12 because this provides the @@ -65,11 +65,6 @@ set cpo&vim command -nargs=* -complete=file -bang Termdebug call s:StartDebug(0, ) command -nargs=+ -complete=file -bang TermdebugCommand call s:StartDebugCommand(0, ) -" Name of the gdb command, defaults to "gdb". -if !exists('g:termdebugger') - let g:termdebugger = 'gdb' -endif - let s:pc_id = 12 let s:asm_id = 13 let s:break_id = 14 " breakpoint number is added to this @@ -99,8 +94,17 @@ call s:Highlight(1, '', &background) hi default debugBreakpoint term=reverse ctermbg=red guibg=red hi default debugBreakpointDisabled term=reverse ctermbg=gray guibg=gray +" Get the command to execute the debugger as a list, defaults to ["gdb"]. func s:GetCommand() - return type(g:termdebugger) == v:t_list ? copy(g:termdebugger) : [g:termdebugger] + if exists('g:termdebug_config') + let cmd = get(g:termdebug_config, 'command', 'gdb') + elseif exists('g:termdebugger') + let cmd = g:termdebugger + else + let cmd = 'gdb' + endif + + return type(cmd) == v:t_list ? copy(cmd) : [cmd] endfunc func s:StartDebug(bang, ...) @@ -144,10 +148,16 @@ func s:StartDebug_internal(dict) let s:save_columns = 0 let s:allleft = 0 - if exists('g:termdebug_wide') - if &columns < g:termdebug_wide + let wide = 0 + if exists('g:termdebug_config') + let wide = get(g:termdebug_config, 'wide', 0) + elseif exists('g:termdebug_wide') + let wide = g:termdebug_wide + endif + if wide > 0 + if &columns < wide let s:save_columns = &columns - let &columns = g:termdebug_wide + let &columns = wide " If we make the Vim window wider, use the whole left half for the debug " windows. let s:allleft = 1 @@ -158,7 +168,12 @@ func s:StartDebug_internal(dict) endif " Override using a terminal window by setting g:termdebug_use_prompt to 1. - let use_prompt = exists('g:termdebug_use_prompt') && g:termdebug_use_prompt + let use_prompt = 0 + if exists('g:termdebug_config') + let use_prompt = get(g:termdebug_config, 'use_prompt', 0) + elseif exists('g:termdebug_use_prompt') + let use_prompt = g:termdebug_use_prompt + endif if has('terminal') && !has('win32') && !use_prompt let s:way = 'terminal' else @@ -171,12 +186,10 @@ func s:StartDebug_internal(dict) call s:StartDebug_term(a:dict) endif - if exists('g:termdebug_disasm_window') - if g:termdebug_disasm_window - let curwinid = win_getid(winnr()) - call s:GotoAsmwinOrCreateIt() - call win_gotoid(curwinid) - endif + if s:GetDisasmWindow() + let curwinid = win_getid(winnr()) + call s:GotoAsmwinOrCreateIt() + call win_gotoid(curwinid) endif if exists('#User#TermdebugStartPost') @@ -240,18 +253,28 @@ func s:StartDebug_term(dict) let proc_args = get(a:dict, 'proc_args', []) let gdb_cmd = s:GetCommand() - " Add -quiet to avoid the intro message causing a hit-enter prompt. - let gdb_cmd += ['-quiet'] - " Disable pagination, it causes everything to stop at the gdb - let gdb_cmd += ['-iex', 'set pagination off'] - " Interpret commands while the target is running. This should usually only - " be exec-interrupt, since many commands don't work properly while the - " target is running (so execute during startup). - let gdb_cmd += ['-iex', 'set mi-async on'] - " Open a terminal window to run the debugger. - let gdb_cmd += ['-tty', pty] - " Command executed _after_ startup is done, provides us with the necessary feedback - let gdb_cmd += ['-ex', 'echo startupdone\n'] + + if exists('g:termdebug_config') && has_key(g:termdebug_config, 'command_add_args') + let gdb_cmd = g:termdebug_config.command_add_args(gdb_cmd, pty) + else + " Add -quiet to avoid the intro message causing a hit-enter prompt. + let gdb_cmd += ['-quiet'] + " Disable pagination, it causes everything to stop at the gdb + let gdb_cmd += ['-iex', 'set pagination off'] + " Interpret commands while the target is running. This should usually only + " be exec-interrupt, since many commands don't work properly while the + " target is running (so execute during startup). + let gdb_cmd += ['-iex', 'set mi-async on'] + " Open a terminal window to run the debugger. + let gdb_cmd += ['-tty', pty] + " Command executed _after_ startup is done, provides us with the necessary + " feedback + let gdb_cmd += ['-ex', 'echo startupdone\n'] + endif + + if exists('g:termdebug_config') && has_key(g:termdebug_config, 'command_filter') + let gdb_cmd = g:termdebug_config.command_filter(gdb_cmd) + endif " Adding arguments requested by the user let gdb_cmd += gdb_args @@ -855,7 +878,13 @@ func s:InstallCommands() command Asm call s:GotoAsmwinOrCreateIt() command Winbar call s:InstallWinbar() - if !exists('g:termdebug_map_K') || g:termdebug_map_K + let map = 1 + if exists('g:termdebug_config') + let map = get(g:termdebug_config, 'map_K', 1) + elseif exists('g:termdebug_map_K') + let map = g:termdebug_map_K + endif + if map let s:k_map_saved = maparg('K', 'n', 0, 1) nnoremap K :Evaluate endif @@ -863,7 +892,13 @@ func s:InstallCommands() if has('menu') && &mouse != '' call s:InstallWinbar() - if !exists('g:termdebug_popup') || g:termdebug_popup != 0 + let popup = 1 + if exists('g:termdebug_config') + let popup = get(g:termdebug_config, 'popup', 1) + elseif exists('g:termdebug_popup') + let popup = g:termdebug_popup + endif + if popup let s:saved_mousemodel = &mousemodel let &mousemodel = 'popup_setpos' an 1.200 PopUp.-SEP3- @@ -1183,6 +1218,26 @@ func s:GotoSourcewinOrCreateIt() endif endfunc +func s:GetDisasmWindow() + if exists('g:termdebug_config') + return get(g:termdebug_config, 'disasm_window', 0) + endif + if exists('g:termdebug_disasm_window') + return g:termdebug_disasm_window + endif + return 0 +endfunc + +func s:GetDisasmWindowHeight() + if exists('g:termdebug_config') + return get(g:termdebug_config, 'disasm_window_height', 0) + endif + if exists('g:termdebug_disasm_window') && g:termdebug_disasm_window > 1 + return g:termdebug_disasm_window + endif + return 0 +endfunc + func s:GotoAsmwinOrCreateIt() if !win_gotoid(s:asmwin) if win_gotoid(s:sourcewin) @@ -1206,10 +1261,8 @@ func s:GotoAsmwinOrCreateIt() exe 'file Termdebug-asm-listing' endif - if exists('g:termdebug_disasm_window') - if g:termdebug_disasm_window > 1 - exe 'resize ' . g:termdebug_disasm_window - endif + if s:GetDisasmWindowHeight() > 0 + exe 'resize ' .. s:GetDisasmWindowHeight() endif endif diff --git a/src/change.c b/src/change.c index 97cc0d712b..5253585463 100644 --- a/src/change.c +++ b/src/change.c @@ -1643,7 +1643,8 @@ open_line( lead_len = get_leader_len(saved_line, &lead_flags, dir == BACKWARD, TRUE); if (lead_len == 0 && curbuf->b_p_cin && do_cindent && dir == FORWARD - && !has_format_option(FO_NO_OPEN_COMS)) + && (!has_format_option(FO_NO_OPEN_COMS) + || (flags & OPENLINE_FORMAT))) { // Check for a line comment after code. comment_start = check_linecomment(saved_line); diff --git a/src/fold.c b/src/fold.c index 26a4a98a76..ee94a979f0 100644 --- a/src/fold.c +++ b/src/fold.c @@ -2574,6 +2574,7 @@ foldUpdateIEMSRecurse( (long)(fp->fd_top - firstlnum)); fp->fd_len += fp->fd_top - firstlnum; fp->fd_top = firstlnum; + fp->fd_small = MAYBE; fold_changed = TRUE; } else if ((flp->start != 0 && lvl == level) diff --git a/src/spellsuggest.c b/src/spellsuggest.c index 4a71438818..5b460a3eaa 100644 --- a/src/spellsuggest.c +++ b/src/spellsuggest.c @@ -1953,7 +1953,8 @@ suggest_trie_walk( #endif ++depth; sp = &stack[depth]; - ++sp->ts_fidx; + if (fword[sp->ts_fidx] != NUL) + ++sp->ts_fidx; tword[sp->ts_twordlen++] = c; sp->ts_arridx = idxs[arridx]; if (newscore == SCORE_SUBST) diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index 67a399ddd8..3bdd99fc0e 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -1528,4 +1528,23 @@ func Test_indent_one_line_fold_close() bw! endfunc +" Make sure that when appending [an indented line then a blank line] right +" before a single indented line, the resulting extended fold can be closed +func Test_indent_append_blank_small_fold_close() + new + setlocal sw=2 foldmethod=indent + " at first, the fold at the second line can't be closed since it's smaller + " than foldminlines + let lines =<< trim END + line 1 + line 4 + END + call setline(1, lines) + call append(1, [' line 2', '']) + " close all folds + normal zM + call assert_notequal(-1, foldclosed(2)) " the fold should be closed now + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_spell_utf8.vim b/src/testdir/test_spell_utf8.vim index 17fa235558..ef08f95352 100644 --- a/src/testdir/test_spell_utf8.vim +++ b/src/testdir/test_spell_utf8.vim @@ -629,7 +629,7 @@ func Test_spell_affix() \ ["bar", "barbork", "end", "fooa1", "fooa\u00E9", "nouend", "prebar", "prebarbork", "start"], \ [ \ ["bad", ["bar", "end", "fooa1"]], - \ ["foo", ["fooa1", "fooa\u00E9", "bar"]], + \ ["foo", ["fooa1", "bar", "end"]], \ ["fooa2", ["fooa1", "fooa\u00E9", "bar"]], \ ["prabar", ["prebar", "bar", "bar bar"]], \ ["probarbirk", ["prebarbork"]], @@ -647,7 +647,7 @@ func Test_spell_affix() \ ["bar", "barbork", "end", "lead", "meea1", "meea\u00E9", "prebar", "prebarbork"], \ [ \ ["bad", ["bar", "end", "lead"]], - \ ["mee", ["meea1", "meea\u00E9", "bar"]], + \ ["mee", ["meea1", "bar", "end"]], \ ["meea2", ["meea1", "meea\u00E9", "lead"]], \ ["prabar", ["prebar", "bar", "leadbar"]], \ ["probarbirk", ["prebarbork"]], @@ -664,7 +664,7 @@ func Test_spell_affix() \ ["bar", "barmeat", "lead", "meea1", "meea\u00E9", "meezero", "prebar", "prebarmeat", "tail"], \ [ \ ["bad", ["bar", "lead", "tail"]], - \ ["mee", ["meea1", "meea\u00E9", "bar"]], + \ ["mee", ["meea1", "bar", "lead"]], \ ["meea2", ["meea1", "meea\u00E9", "lead"]], \ ["prabar", ["prebar", "bar", "leadbar"]], \ ["probarmaat", ["prebarmeat"]], @@ -758,11 +758,15 @@ func Test_spell_sal_and_addition() set spl=Xtest_ca.utf-8.spl call assert_equal("elequint", FirstSpellWord()) call assert_equal("elekwint", SecondSpellWord()) + + set spellfile= + set spl& endfunc func Test_spellfile_value() set spellfile=Xdir/Xtest.utf-8.add set spellfile=Xdir/Xtest.utf-8.add,Xtest_other.add + set spellfile= endfunc func Test_no_crash_with_weird_text() @@ -785,5 +789,18 @@ func Test_check_for_valid_word() call assert_fails("spellgood! 0\xac", 'E1280:') endfunc +" This was going over the end of the word +func Test_word_index() + new + norm R0 + spellgood! fl0 + sil norm z= + + bwipe! + " clear the word list + set enc=utf-8 + call delete('Xtmpfile') +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/testdir/test_textformat.vim b/src/testdir/test_textformat.vim index 9630e8d150..d33e2508d2 100644 --- a/src/testdir/test_textformat.vim +++ b/src/testdir/test_textformat.vim @@ -289,11 +289,28 @@ func Test_format_c_comment() x END call assert_equal(expected, getline(1, '$')) + + " Comment is formatted when it wraps + normal 2GA with some more text added + let expected =<< trim END + nop; + val = val; // This is a comment + // with some more text + // added + x + END + call assert_equal(expected, getline(1, '$')) + set fo-=/ " using 'indentexpr' instead of 'cindent' does not repeat a comment setl nocindent indentexpr=2 - 3delete + %del + let text =<< trim END + nop; + val = val; // This is a comment + END + call setline(1, text) normal 2Gox let expected =<< trim END nop; diff --git a/src/textformat.c b/src/textformat.c index a6a3b4dc67..7e32c1ccc3 100644 --- a/src/textformat.c +++ b/src/textformat.c @@ -371,6 +371,7 @@ internal_format( open_line(FORWARD, OPENLINE_DELSPACES + OPENLINE_MARKFIX + (fo_white_par ? OPENLINE_KEEPTRAIL : 0) + (do_comments ? OPENLINE_DO_COM : 0) + + OPENLINE_FORMAT + ((flags & INSCHAR_COM_LIST) ? OPENLINE_COM_LIST : 0) , ((flags & INSCHAR_COM_LIST) ? second_indent : old_indent), &did_do_comment); diff --git a/src/version.c b/src/version.c index 21b97c613c..e01b7ded0f 100644 --- a/src/version.c +++ b/src/version.c @@ -749,6 +749,14 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 5010, +/**/ + 5009, +/**/ + 5008, +/**/ + 5007, /**/ 5006, /**/ diff --git a/src/vim.h b/src/vim.h index 64d41907f2..25d6206a4d 100644 --- a/src/vim.h +++ b/src/vim.h @@ -1126,11 +1126,12 @@ extern int (*dyn_libintl_wputenv)(const wchar_t *envstring); #define INSCHAR_COM_LIST 16 // format comments with list/2nd line indent // flags for open_line() -#define OPENLINE_DELSPACES 1 // delete spaces after cursor -#define OPENLINE_DO_COM 2 // format comments -#define OPENLINE_KEEPTRAIL 4 // keep trailing spaces -#define OPENLINE_MARKFIX 8 // fix mark positions -#define OPENLINE_COM_LIST 16 // format comments with list/2nd line indent +#define OPENLINE_DELSPACES 0x01 // delete spaces after cursor +#define OPENLINE_DO_COM 0x02 // format comments +#define OPENLINE_KEEPTRAIL 0x04 // keep trailing spaces +#define OPENLINE_MARKFIX 0x08 // fix mark positions +#define OPENLINE_COM_LIST 0x10 // format comments with list/2nd line indent +#define OPENLINE_FORMAT 0x20 // formatting long comment // There are five history tables: #define HIST_CMD 0 // colon commands