[vim/vim] :delete reports one fewer line when deleting the entire buffer (Issue #21049)
Narendran Gopalakrishnan (Vim Github Repository) <[email protected]>
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <vim/vim/issues/[email protected]> |
gnarendran created an issue (vim/vim#21049)
### Steps to reproduce
When `:delete` deletes all lines in a buffer, the reported number of fewer lines is one less than the number of lines actually deleted.
For example, with a four-line buffer, deleting `1,$` removes all four lines, but reports `3 fewer lines`. Deleting `2,$` from the same four-line buffer correctly reports `3 fewer lines`.
Minimal reproduction:
```vim
function! CmdMsg(cmd) abort
" First force the preceding change into a separate undo block.
let &g:undolevels = &g:undolevels
let l:msg = ''
redir => l:msg
execute 'silent ' . a:cmd
redir END
echomsg printf('Message from "%s": ', a:cmd) . trim(l:msg)
endfunction
call setline(1, ['one', 'two', 'three', 'four'])
call CmdMsg('1,$delete')
call CmdMsg('undo')
call CmdMsg('2,$delete')
call getchar()
quit!
```
Output of:
vi --clean -u theAboveScript
```text
Message from "1,$delete": 3 fewer lines
Message from "undo": 4 more lines; before #2 0 seconds ago
Message from "2,$delete": 3 fewer lines
```
The first command deletes all four lines, leaving the buffer's required empty line, but the message appears to report the change in buffer line count rather than the number of lines actually deleted.
The second deletion is a useful comparison: it deletes three lines and correctly reports `3 fewer lines`.
### Expected behaviour
When `:delete` makes the buffer empty, it should correctly report the number of fewer lines, like in cases when buffer doesn't become empty.
### Version of Vim
vim 9.2.920
### Environment
Fedora44
XTerm(406)
xterm-256color
bash
### Logs and stack traces
```shell
```
--
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/issues/21049
You are receiving this because you are subscribed to this thread.
Message ID: <vim/vim/issues/[email protected]>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/21049%40github.com.