diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | src/nvim/event/stream.c | 7 | ||||
-rw-r--r-- | src/nvim/fold.c | 26 | ||||
-rw-r--r-- | src/nvim/misc1.c | 2 | ||||
-rw-r--r-- | src/nvim/normal.c | 5 | ||||
-rw-r--r-- | src/nvim/testdir/test_fold.vim | 16 | ||||
-rw-r--r-- | test/functional/fixtures/tty-test.c | 3 | ||||
-rw-r--r-- | test/functional/ui/mode_spec.lua | 6 |
8 files changed, 51 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore index 68dbb7588a..7db3d96e2b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,6 +42,8 @@ tags /src/nvim/testdir/valgrind.* /src/nvim/testdir/.gdbinit /runtime/indent/testdir/*.out +# Generated by src/nvim/testdir/runnvim.sh. +/src/nvim/testdir/*.tlog # Generated by unit tests. /test/includes/post/ diff --git a/src/nvim/event/stream.c b/src/nvim/event/stream.c index 7c8014dead..d1a53fa4b6 100644 --- a/src/nvim/event/stream.c +++ b/src/nvim/event/stream.c @@ -97,6 +97,13 @@ void stream_close(Stream *stream, stream_close_cb on_stream_close, void *data) stream->close_cb = on_stream_close; stream->close_cb_data = data; +#ifdef WIN32 + if (UV_TTY == uv_guess_handle(stream->fd)) { + // Undo UV_TTY_MODE_RAW from stream_init(). #10801 + uv_tty_set_mode(&stream->uv.tty, UV_TTY_MODE_NORMAL); + } +#endif + if (!stream->pending_reqs) { stream_close_handle(stream); } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index ad0bfe29e2..5ce953e626 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1645,19 +1645,22 @@ deleteFoldMarkers( foldendmarkerlen); } -/* foldDelMarker() {{{2 */ -/* - * Delete marker "marker[markerlen]" at the end of line "lnum". - * Delete 'commentstring' if it matches. - * If the marker is not found, there is no error message. Could a missing - * close-marker. - */ +// foldDelMarker() {{{2 +// +// Delete marker "marker[markerlen]" at the end of line "lnum". +// Delete 'commentstring' if it matches. +// If the marker is not found, there is no error message. Could be a missing +// close-marker. static void foldDelMarker(linenr_T lnum, char_u *marker, size_t markerlen) { char_u *newline; char_u *cms = curbuf->b_p_cms; char_u *cms2; + // end marker may be missing and fold extends below the last line + if (lnum > curbuf->b_ml.ml_line_count) { + return; + } char_u *line = ml_get(lnum); for (char_u *p = line; *p != NUL; ++p) { if (STRNCMP(p, marker, markerlen) != 0) { @@ -2426,15 +2429,18 @@ static linenr_T foldUpdateIEMSRecurse( * lvl >= level: fold continues below "bot" */ - /* Current fold at least extends until lnum. */ + // Current fold at least extends until lnum. if (fp->fd_len < flp->lnum - fp->fd_top) { fp->fd_len = flp->lnum - fp->fd_top; fp->fd_small = kNone; fold_changed = true; + } else if (fp->fd_top + fp->fd_len > linecount) { + // running into the end of the buffer (deleted last line) + fp->fd_len = linecount - fp->fd_top + 1; } - /* Delete contained folds from the end of the last one found until where - * we stopped looking. */ + // Delete contained folds from the end of the last one found until where + // we stopped looking. foldRemove(&fp->fd_nested, startlnum2 - fp->fd_top, flp->lnum - 1 - fp->fd_top); diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index 44e2c7df5f..bb95cd5737 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -61,7 +61,7 @@ #ifdef INCLUDE_GENERATED_DECLARATIONS # include "misc1.c.generated.h" #endif -/* All user names (for ~user completion as done by shell). */ +// All user names (for ~user completion as done by shell). static garray_T ga_users = GA_EMPTY_INIT_VALUE; /* diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 73841cf449..bfd91e688e 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -7827,13 +7827,15 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) // 'virtualedit' and past the end of the line, we use the 'c' operator in // do_put(), which requires the visual selection to still be active. if (!VIsual_active || VIsual_mode == 'V' || regname != '.') { - // Now delete the selected text. + // Now delete the selected text. Avoid messages here. cap->cmdchar = 'd'; cap->nchar = NUL; cap->oap->regname = NUL; + msg_silent++; nv_operator(cap); do_pending_operator(cap, 0, false); empty = (curbuf->b_ml.ml_flags & ML_EMPTY); + msg_silent--; // delete PUT_LINE_BACKWARD; cap->oap->regname = regname; @@ -7882,6 +7884,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent) * line that needs to be deleted now. */ if (empty && *ml_get(curbuf->b_ml.ml_line_count) == NUL) { ml_delete(curbuf->b_ml.ml_line_count, true); + deleted_lines(curbuf->b_ml.ml_line_count + 1, 1); /* If the cursor was in that line, move it to the end of the last * line. */ diff --git a/src/nvim/testdir/test_fold.vim b/src/nvim/testdir/test_fold.vim index df3d691d85..4036eae678 100644 --- a/src/nvim/testdir/test_fold.vim +++ b/src/nvim/testdir/test_fold.vim @@ -740,3 +740,19 @@ func Test_folds_marker_in_comment2() set foldmethod& bwipe! endfunc + +func Test_fold_delete_with_marker() + new + call setline(1, ['func Func() {{{1', 'endfunc']) + 1,2yank + new + set fdm=marker + call setline(1, 'x') + normal! Vp + normal! zd + call assert_equal(['func Func() ', 'endfunc'], getline(1, '$')) + + set fdm& + bwipe! + bwipe! +endfunc diff --git a/test/functional/fixtures/tty-test.c b/test/functional/fixtures/tty-test.c index e2a78a594b..4438b73a22 100644 --- a/test/functional/fixtures/tty-test.c +++ b/test/functional/fixtures/tty-test.c @@ -38,6 +38,9 @@ bool owns_tty(void) static void walk_cb(uv_handle_t *handle, void *arg) { if (!uv_is_closing(handle)) { +#ifdef WIN32 + uv_tty_set_mode(&tty, UV_TTY_MODE_NORMAL); +#endif uv_close(handle, NULL); } } diff --git a/test/functional/ui/mode_spec.lua b/test/functional/ui/mode_spec.lua index f6b3c1c3c9..a09df075aa 100644 --- a/test/functional/ui/mode_spec.lua +++ b/test/functional/ui/mode_spec.lua @@ -2,8 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert -local command, eval = helpers.command, helpers.eval -local eq = helpers.eq +local command = helpers.command describe('ui mode_change event', function() local screen @@ -63,7 +62,7 @@ describe('ui mode_change event', function() ]], mode="normal"} command("set showmatch") - eq(eval('&matchtime'), 5) -- tenths of seconds + command("set matchtime=1") -- tenths of seconds feed('a(stuff') screen:expect{grid=[[ word(stuff^ | @@ -80,7 +79,6 @@ describe('ui mode_change event', function() {2:-- INSERT --} | ]], mode="showmatch"} - screen:sleep(400) screen:expect{grid=[[ word(stuff)^ | {0:~ }| |