This looks like a bug, worth creating an issue in vim's github.
echo getbufinfo(bufnr()) says that `changed: 0` however `changedtick` is greater than 0
As for
specified filetype or to provide that service for other files
check :h skeleton
But it would have the same issue as with Filetype
On Friday, October 2, 2026 at 12:41:59 PM UTC+10 Mike wrote:
Hi all,
I'm seeing unexpected behavior when using an autocmd defined in a
plugin. A simplified version of the plugin is the following:
function! InsertText()
echomsg "modified option is " .. &modified
call append(line("$"), "section title")
echomsg "modified option is " .. &modified
endfunction
autocmd FileType fortran call InsertText()
command -nargs=0 ForNoFT call InsertText()
It's purpose is to automatically insert lines in files that have a
specified filetype or to provide that service for other files. In the
above example, I've used "fortran" but I think any vim-recognized
filetype will do.
To show the problem, edit a Fortran file, e.g. run "vim test.f90". You
will see the text "section title" in the buffer. However, even though
the 'modified' option is set, I am allowed to quit vim (:q). Also, ^G
does not show modified. This behavior occurs whether the file
"test.f90" is new or has content.
A user-command has been defined in the plugin, intended for files
without a filetype. When you run "vim test.unknown" and then run the
user-command "ForNoFT", quit will fail as expected and ^G will show
modified.
Interestingly, if 'modified' is explicitly set in the function, then vim
will not quit because it sees test.f90 as modified.
My question is why the difference?
I'm running vim 9.2.1036 with normal features on Windows 10.
Thanks for any help.
-mike
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/vim_use/de73247d-1ee9-4ad8-9991-1f7ca8dca8a4n%40googlegroups.com.
No comments:
Post a Comment