diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2018-11-11 13:13:14 -0500 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-11-11 19:13:14 +0100 |
commit | 9f3fb66111d3a7923106df60837f3150b3cf55b9 (patch) | |
tree | e6d8ae4fc4e7b56ded377f61efacb5a378f9d4a0 /src/nvim/ex_cmds.c | |
parent | c936ae0f3688d1cf159506d2d9ba3f9be41298a2 (diff) | |
download | rneovim-9f3fb66111d3a7923106df60837f3150b3cf55b9.tar.gz rneovim-9f3fb66111d3a7923106df60837f3150b3cf55b9.tar.bz2 rneovim-9f3fb66111d3a7923106df60837f3150b3cf55b9.zip |
vim-patch:8.1.0516: :move command sets 'modified' #9224
Problem: :move command marks buffer modified when nothing changed.
Solution: Do not set 'modified'. Add a test. (Jason Franklin)
https://github.com/vim/vim/commit/ddd1f9183bed00d096f29c503721ac559174a29f
Diffstat (limited to 'src/nvim/ex_cmds.c')
-rw-r--r-- | src/nvim/ex_cmds.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index dc942eb0b3..0a9b6ecc57 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -816,10 +816,23 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) linenr_T last_line; // Last line in file after adding new text if (dest >= line1 && dest < line2) { - EMSG(_("E134: Move lines into themselves")); + EMSG(_("E134: Cannot move a range of lines into itself")); return FAIL; } + // Do nothing if we are not actually moving any lines. This will prevent + // the 'modified' flag from being set without cause. + if (dest == line1 - 1 || dest == line2) { + // Move the cursor as if lines were moved (see below) to be backwards + // compatible. + if (dest >= line1) { + curwin->w_cursor.lnum = dest; + } else { + curwin->w_cursor.lnum = dest + (line2 - line1) + 1; + } + return OK; + } + num_lines = line2 - line1 + 1; /* |