Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scratch buffer (bt=nofile) support #139

Open
KSR-Yasuda opened this issue Jun 1, 2022 · 3 comments
Open

Scratch buffer (bt=nofile) support #139

KSR-Yasuda opened this issue Jun 1, 2022 · 3 comments

Comments

@KSR-Yasuda
Copy link
Contributor

Couldn't you support scratch buffer (bt=nofile)?

I sometimes use a scratch buffer to put some temporary notes in it.
Though, Undotree plugin doesn't work for it.

I found it ignores nofile buffer with some intention.
Fix as below makes scratch buffers supported.

Is it the reason that nofile buffers are often used for plugins' status windows or such?

--- a/autoload/undotree.vim
+++ b/autoload/undotree.vim
@@ -569,8 +569,8 @@ function! s:undotree.Update() abort
     if exists('b:isUndotreeBuffer')
         return
     endif
-    if (&bt != '' && &bt != 'acwrite') || (&modifiable == 0) || (mode() != 'n')
-        if &bt == 'quickfix' || &bt == 'nofile'
+    if (&bt != '' && &bt != 'acwrite' && &bt != 'nofile') || (&modifiable == 0) || (mode() != 'n')
+        if &bt == 'quickfix'
             "Do nothing for quickfix and q:
             call s:log("undotree.Update() ignore quickfix")
             return
@mbbill
Copy link
Owner

mbbill commented Jun 1, 2022

nofile buffers are pretty widely used by plugins to display some non-content information.

@KSR-Yasuda
Copy link
Contributor Author

I know,
but use case for scratch buffer is also well-know usage, isn't it? (See :help scratch-buffer)

For such plugins' info windows, users do not open UndoTree window purposely.
So I suppose supporting scratch buffer is more worthful.

@mbbill
Copy link
Owner

mbbill commented Jun 1, 2022

It's quite likely. I agree scratch buffers are also useful but the problem is that it's difficult to distinguish the scratch buffers from other info windows. For instance many users will keep something like NERDTree on a side, and that's nofile buffer. So when the undotree pops up, it has to ignore such buffers, and we can't force users to turn the NERDTree off before using the undotree.
That's said, I think we can make it an option in case users doesn't care about the scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants