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

Add last modified buffer (gm) #3814

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pickfire
Copy link
Contributor

Behaves similar to vim ^ such that it jumps to buffer that was modified.
Internally, it keeps two last modified buffer, it behaves like a stack
and push the buffer when there is a new modified buffer and it also
prevents both last modified buffers pointing to the same buffer.

This broke my workflow a lot so I came in and write some C++, hopefully
I got it correct.

Fix #3607

Behaves similar to vim ^ such that it jumps to buffer that was modified.
Internally, it keeps two last modified buffer, it behaves like a stack
and push the buffer when there is a new modified buffer and it also
prevents both last modified buffers pointing to the same buffer.

This broke my workflow a lot so I came in and write some C++, hopefully
I got it correct.

Fix mawww#3607
@lenormf
Copy link
Contributor

lenormf commented Oct 18, 2020

Solid feature. I've only looked into the implementation superficially, but here are some remarks:

@pickfire
Copy link
Contributor Author

why two pointers?

If there is only one pointers, if we switched to another buffer without modifying the current one, it we always jump to the original one. If say the second buffer is the previous modified file, it should jump to the same file? So we need two buffers to jump between alternative modified buffers as we cannot guarantee that the buffers are always modified when we change buffers.

why use a sentinel (m_modified_since_accessed)?

Err, I tried using history but I didn't get that method working, we need a sentinel. Say if we changed many files, you happened to jump from one of the files that was previously modified but not one of the last two pointers, if would jump to that file even though that was modified after many modified buffers jumps.

is #1993 impacted by this patch?

No, having the sentinel does not impact that, if we chose two change the history like vim default nohidden, we could not keep the history of the previous buffers which I think is bad.

@pickfire
Copy link
Contributor Author

pickfire commented Nov 1, 2020

Should we add changelog for this?

@pickfire
Copy link
Contributor Author

@mawww Ping

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

Successfully merging this pull request may close these issues.

Last modified buffer
2 participants