diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/indent.c | 19 | ||||
-rw-r--r-- | src/nvim/testdir/test_retab.vim | 10 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 32cdf6f2d6..0ffa152af7 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -918,6 +918,16 @@ bool may_do_si(void) return curbuf->b_p_si && !curbuf->b_p_cin && *curbuf->b_p_inde == NUL && !p_paste; } +/// Give a "resulting text too long" error and maybe set got_int. +static void emsg_text_too_long(void) +{ + emsg(_(e_resulting_text_too_long)); + // when not inside a try/catch set got_int to break out of any loop + if (trylevel == 0) { + got_int = true; + } +} + /// ":retab". void ex_retab(exarg_T *eap) { @@ -1009,7 +1019,7 @@ void ex_retab(exarg_T *eap) old_len = (long)strlen(ptr); const long new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { - emsg(_(e_resulting_text_too_long)); + emsg_text_too_long(); break; } new_line = xmalloc((size_t)new_len); @@ -1045,12 +1055,7 @@ void ex_retab(exarg_T *eap) } vcol += win_chartabsize(curwin, ptr + col, (colnr_T)vcol); if (vcol >= MAXCOL) { - emsg(_(e_resulting_text_too_long)); - // when not inside a try/catch set got_int to break out of any - // loop - if (trylevel == 0) { - got_int = true; - } + emsg_text_too_long(); break; } col += utfc_ptr2len(ptr + col); diff --git a/src/nvim/testdir/test_retab.vim b/src/nvim/testdir/test_retab.vim index 4253e77487..a4f95053c0 100644 --- a/src/nvim/testdir/test_retab.vim +++ b/src/nvim/testdir/test_retab.vim @@ -92,7 +92,7 @@ func RetabLoop() endfunc func Test_retab_endless() - " inside try/catch we catch the error message + " inside try/catch we can catch the error message call setline(1, "\t0\t") let caught = 'no' try @@ -106,13 +106,7 @@ func Test_retab_endless() endfunc func Test_nocatch_retab_endless() - " FIXME: why does this hang on MS-Windows? Is got_int reset somewhere? - if has('win32') - let g:skipped_reason = "does not work on MS-Windows" - return - endif - - " not inside try/catch an interrupt is generated to get out of loops + " when not inside try/catch an interrupt is generated to get out of loops call setline(1, "\t0\t") call assert_fails('call RetabLoop()', ['E1240:', 'Interrupted']) |