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 alternate file #223

Merged
merged 5 commits into from
Jun 12, 2021
Merged

add alternate file #223

merged 5 commits into from
Jun 12, 2021

Conversation

robinvd
Copy link
Contributor

@robinvd robinvd commented Jun 11, 2021

inspired by vim ctrl-6/kak ga commands. the alternate file is kept per view

inspired by vim ctrl-6/kak ga commands. the alternate file is kept per view
Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I've been missing this feature! Just a few minor comments.

@@ -88,6 +88,12 @@ impl Editor {
pub fn switch(&mut self, id: DocumentId, action: Action) {
use crate::tree::Layout;
use helix_core::Selection;

if !self.documents.contains_key(id) {
log::warn!("cannot switch to document that does not exist (anymore)");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this log::error!, ideally this shouldn't happen. We'll need to add something like forget_doc on the view to remove it from both alternate file and the jumplist: https://github.com/mawww/kakoune/blob/c507863a00289fe4b210ecc4fef5554de4c87bf4/src/context.cc#L197-L210

@@ -67,6 +67,7 @@ pub struct View {
pub first_col: usize,
pub area: Rect,
pub jumps: JumpList,
pub alternate_file: Option<DocumentId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this alternate_doc to match the doc field.

@pickfire
Copy link
Contributor

I wish it could be like vim ^, ga is not very useful for me since I always browse file, maybe I will port the patch I sent for kakaoune mawww/kakoune#3814 here. For last modified file which behaves more like vim. So browsing file don't need to override it.

@robinvd robinvd requested a review from archseer June 12, 2021 08:46
@robinvd
Copy link
Contributor Author

robinvd commented Jun 12, 2021

@pickfire i think that would be a great addition as well

@pickfire
Copy link
Contributor

@robinvd Can you change those alternate to last_accessed to be clearer so stuff will be easier once I add the other one?

@robinvd
Copy link
Contributor Author

robinvd commented Jun 12, 2021

@pickfire done

Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Not tested but I will test later.

@pickfire
Copy link
Contributor

pickfire commented Jun 12, 2021

Tested, works nicely. But I think it would be better to have a text in the status line saying "no last accessed file" when ga is pressed without last accessed file.

@robinvd robinvd requested a review from pickfire June 12, 2021 12:12
@archseer archseer merged commit 44cc0d8 into helix-editor:master Jun 12, 2021
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.

3 participants