Skip to content

feat: Show filepath context in bufferline #13565

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

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

Conversation

icorbrey
Copy link

@icorbrey icorbrey commented May 18, 2025

This change adds functionality that computes the shortest unique filepath for each document in the editor to display as the title in the bufferline, along with the appropriate configuration options.

Configuration changes

editor.bufferline has been moved to editor.bufferline.show, and a new key editor.bufferline.context has been added with the following variants:

  • "none": Don't provide any additional context in the bufferline. This maintains previous functionality.
  • "minimal": Show the shortest unique filepath for each document in the bufferline. This is the new default.

Setting the render mode directly in editor.bufferline is still supported, so existing configs won't break.

Functionality

With editor.bufferline.context = "none", the following set of documents is mapped as follows:

Path Bufferline text
book/src/editor.md editor.md
helix-term/src/ui/editor.rs editor.rs
helix-view/src/editor.rs editor.rs

With editor.bufferline.context = "minimal", the same set of documents is now mapped as follows:

Path Bufferline text
book/src/editor.md editor.md
helix-term/src/ui/editor.rs ui/editor.rs
helix-view/src/editor.rs src/editor.rs

Verification steps

  1. Set editor.bufferline.show to always.
  2. Open multiple buffers pointed at the files with the same filename.
    • Those buffers should show enough of their files' paths to be unique.
  3. Open another buffer with a different name.
    • That buffer should only show the filename.
  4. Set editor.bufferline.context to none.
    • The buffer titles should now show the filename only.

Possible additions

We could add another context variant "full" which would map documents to their full path (either from Helix's working directory or, if outside that, from the user's home directory (e.g. ~/...) or from the system root (e.g. /...).

@icorbrey icorbrey force-pushed the feat/bufferline-context branch from 99a23ae to 0676f6a Compare May 18, 2025 15:41
@icorbrey icorbrey marked this pull request as ready for review May 18, 2025 16:19
@icorbrey icorbrey force-pushed the feat/bufferline-context branch 2 times, most recently from 1abbf96 to 7d43d39 Compare May 18, 2025 23:39
Copy link
Contributor

@CalebLarsen CalebLarsen left a comment

Choose a reason for hiding this comment

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

Only a couple of small changes that came to mind. Other than that, looks good :)

@icorbrey icorbrey force-pushed the feat/bufferline-context branch 2 times, most recently from 8165ca5 to eecd9ae Compare May 21, 2025 13:54
@icorbrey icorbrey requested a review from CalebLarsen May 21, 2025 13:54
Copy link
Contributor

@CalebLarsen CalebLarsen 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, nice work!

Copy link

@DerSaidin DerSaidin left a comment

Choose a reason for hiding this comment

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

Hello! Seeing the many many pull requests, I want to try helping out with some code reviews. I'm new to helix, so weight my review accordingly.

@DerSaidin
Copy link

Related: #13113

/// editor. For example, documents `a/b` and `c/d` would resolve to `b` and `d`
/// respectively, while `a/b/c` and `a/d/c` would resolve to `b/c` and `d/c`
/// respectively.
fn expand_fname_contexts<'a>(editor: &'a Editor, scratch: &'a str) -> HashMap<DocumentId, String> {

Choose a reason for hiding this comment

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

Instead of taking editor, could this take less context?

e.g. pass in documents: BTreeMap<DocumentId, Document>, or possibly just the Option, not the whole Document.

Related: could this function have a unit test below?

Copy link
Author

Choose a reason for hiding this comment

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

Re: unit test, it probably could but I wasn't sure if it would be a value add for the project. There seem to be very few unit tests in here.

Choose a reason for hiding this comment

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

Imo tests are good, and adding tests is better than not :)

This change adds functionality that computes the shortest unique
filepath for each document in the editor to display as the title in the
bufferline, along with the appropriate configuration options.
@icorbrey icorbrey force-pushed the feat/bufferline-context branch from 9183108 to bc0f718 Compare June 10, 2025 18:39
/// editor. For example, documents `a/b` and `c/d` would resolve to `b` and `d`
/// respectively, while `a/b/c` and `a/d/c` would resolve to `b/c` and `d/c`
/// respectively.
fn expand_fname_contexts<'a>(editor: &'a Editor, scratch: &'a str) -> HashMap<DocumentId, String> {

Choose a reason for hiding this comment

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

Imo tests are good, and adding tests is better than not :)

@icorbrey
Copy link
Author

@the-mikedavis I don't know who to ask, but could I get checks run on my PR?

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.

4 participants