Problem:
After I have opened the tutor with :Tutor, then I close its window with :q, then if I run :Tutor to open the tutor again, it will open an empty buffer instead of the tutor content. This is a very confusing behavior.
Related issue neovim/neovim#36228
Solution:
I believe the point of set buftype=nofile is just to prevent users from accidentally writing changes to the tutor file, so why not use nowrite instead?
  https://github.com/vim/vim/pull/18613
(1Â file)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@brianhuster pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I can't reproduce it with the steps provided.
https://asciinema.org/a/tgKyl8dmRSrIdQ3BsW0DragCT
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
However if you :e within :Tutor it will wipe out the buffer. Here set buftype=nowrite doesn't help.
Or just do :Tutor and then again :Tutor. Here set buftype=nowrite helps.
I believe a better solution might be to come up with BufReadCmd to populate buffer properly on occasional :e and other related commands.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
If you add autocmd! BufReadCmd <buffer> :Tutor
" Enables/disables interactive mode.
function! tutor#EnableInteractive(enable)
let enable = a:enable
if enable
setlocal buftype=nowrite
setlocal concealcursor+=inv
setlocal conceallevel=2
call tutor#ApplyMarks()
augroup tutor_interactive
autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
autocmd! BufReadCmd <buffer> :Tutor
augroup END
...
Together with set buftype=nowrite it would also fix issue with :e.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Well, it needs to be smarter: it should know what tutorial was loaded into the buffer and read it back within BufReadCmd.
PS, original tutorial ftw :)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Or just do :Tutor and then again :Tutor. Here set buftype=nowrite helps.
This is what I was trying to solve.
Well, it needs to be smarter: it should know what tutorial was loaded into the buffer and read it back within BufReadCmd.
Tutor is not a part of anyone's workflow, so I don't want to put too much time on it. I also support removing the new tutor btw.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Thanks. Let's also make it :drop instead of edit, so it works even when the current buffer is modified
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Let's also make it :drop instead of edit, so it works even when the current buffer is modified
@chrisbra Why doesn't :edit work when the current buffer is modified? Can you please elaborate on that?
Also, you have not explained that change in the commit message.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Why doesn't :edit work when the current buffer is modified? Can you please elaborate on that?
Try yourself: :set modified| :e and notice the E37.
Also, you have not explained that change in the commit message.
Indeed, but now it is set in stone 🤷
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()