-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 configuration for min width of line-numbers gutter #4724
Conversation
I wonder if this is necessary after #3469? You would have to be editing a really massive file for the gutter to be noticeably large |
Agree, we can offer a configurable minimum but no maximum. |
@the-mikedavis - I can only speak for myself, but I really try to cut down on the unused space in the gutters. In I don't feel as strongly about a maximum, but it seemed like an easy related addition. I would use it if it was available. |
I think a min of
|
In most cases the line number column is going to be under 5-6 columns (10_000 - 100_000 lines), and any larger than that would be a pain to load fully into memory anyway. |
I suggested this, and in retrospect it wouldn't matter. If a document has <10 lines, then the maximum relative offset is also <10, so you don't need two characters devoted to relative numbering. Anyways, if this whole PR feels unnecessary to you - that's fine too. Feel free to close the request. Either way I'm grateful for the opportunity to get my fingers into some rust development with a clean codebase and will look for the next task to chip away at. |
@archseer @the-mikedavis I've altered the implementation so that only minimum linenumber gutter width is configurable. This is ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a good way to configure gutters to me 👍. We will probably end up using this in the future to allow configuration of the characters used for additions/modifications/deletions in the diff gutter element and maybe the separator character (as with the statusline, although I can't imagine anything other than space looking good)
@the-mikedavis @pascalkuthe - Thank you both for reviewing and for the suggestions on how to better handle the different styles of configuration. I've incorporated your feedback. This PR is now ready for another pass of review. |
|
||
#### `[editor.gutters.spacer]` Section | ||
|
||
Currently unused |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about [editor.gutters.breakpoints]
? I’m mentioning this because of what I’m doing in #5371 (I might eventually rebase on your work).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now the sub-sections are styled after the names that can be provided to editor.gutters
. There's no real reason it must be like this, but it think there's some discoverability benefit to being consistent here.
Following that style, both breakpoints and diagnostics would be configured in editors.gutters.diagnostics
. I think it's best to follow this precedent, but I'd say this is a call for some of the more core contributors like @the-mikedavis
Looking into the future a bit further, I think the underlying issue here is that diagnostics and breakpoints are a bit oddly coupled - likely a solution from before gutters were configurable. I think there's a case for decoupling diagnostics and breakpoints and trying to tackle that use case more generically. I think it would be interesting to be able to layer gutters as part of the layout. Perhaps something like:
[editor.gutters]
layout = [ [ "diagnostics", "breakpoints" ], "line-numbers" ]
Which would provide the current behavior. I think that needs more discussion before jumping to something like that, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m reimplementing #5371 rebased atop your PR then.
@the-mikedavis, @archseer - Any chance I can get your eyes on this PR for review? It's beginning to be used by downstream work, so I'm feeling obliged to push it forward. |
Agreed, it would be nice to be able to merge it. Rebasing my PR (#5371) requires rebasing that one so I can’t really be up-to-date with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good overall, just some minor comments
Thank you for the review today @the-mikedavis - I applied all but one change that I wasn't quite clear on. |
Small nit question: have you rebased on |
@phaazon - I rebased onto master so hopefully it's easier on you now if you want to use this as the basis for your changes. |
Supercedes #3953
Now that the line-number gutter can be resized (#3469), this exposes options for the currently hard-coded minimum number of characters used in the line-numbers gutter.
Architectural Changes
GutterConfig
&GutterLineNumbersConfig
config structs added, allowing for the configuration style suggested in #1188.View
now accepts agutters
parameter as aGutterConfig
object instead ofVec<GutterType>
Editor::refresh_config()
now also refreshesView
s to respond to configuration update eventsDesign feedback needed
editor.gutters
provided as an array of strings be deprecated in favor ofeditor.gutters.layout
?