-
Notifications
You must be signed in to change notification settings - Fork 106
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
Show percentage through the file in the statusline/modeline #246
Open
oldaccountdeadname
wants to merge
6
commits into
jmacdonald:main
Choose a base branch
from
oldaccountdeadname:percent-through
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Show percentage through the file in the statusline/modeline #246
oldaccountdeadname
wants to merge
6
commits into
jmacdonald:main
from
oldaccountdeadname:percent-through
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I like it! I have a couple of questions/suggestions:
|
The percentage seems based on the cursor position, but it might be
better to use the last visible line of the window. That would prevent
the number from changing when the cursor is moved within the window,
which feels distracting. I also tend to think of these indicators as
answering "how far down in the document am I looking?", which aligns
with the window. Any idea what other editors have landed on for this?
Hm, interesting. I hadn't thought of it that way. As for what other
editors do, Neovim looks to provide this percentage via the location of
the cursor (in src/nvim/buffer.c, line 4022, current HEAD),
though I'm not sure about anything else. What would you think about a
config toggle for it? I think this might just be a matter of personal
taste and/or what people are used to.
Though FWIW, I've been using this basically since I patched it in
(add8bbc), and I haven't found the constant changing distracting. The
indicator only pops up in normal mode, where the cursor can't really
change positions, so I personally like it as is given the extra
'precision' of the cursor. Happy to add in a config option if you think
it's a good idea, though.
* Does the percentage still display if all of the buffer content fits
on-screen? This relates to my earlier point: if it's meant to be an
indicator of the how far down the window is looking into the buffer,
we should hide it if the answer to that question is obvious.
Oh, I hadn't thought of that - done in fc43e26!
* I kinda feel like it might be a better fit at the end of the line,
since it's not _critical_ information, unlike the name or editor mode.
What do you think?
|
This will make following changes (adding a position indicator) moderately simpler.
A modeline may look like, for instance: NORMAL [17%] src/presenters/mod.rs as opposed to the previous: NORMAL src/presenters/mod.rs This is a small & slightly opinionated change.
The previous logic to display the statusline did so by right aligning only the last element. This isn't sufficient if more than one element is to appear on the right (e.g., a cursor position indicator). So, this commit replaces the logic to first render the right elements as compactly as possible, then render the first left elements as compactly as possible, but expand out the last left element to fill the remaining space. Behavior is identical; this is purely an API change.
This only applies to normal mode, and is a straightforward extension of ff0dc68's modifications.
This modifies the display function in normal mode without changing the logic to gather the percentage, and should make the statusline a bit cleaner on small files.
oldaccountdeadname
force-pushed
the
percent-through
branch
from
January 23, 2022 21:56
fc43e26
to
852da93
Compare
I rebased the commits to fix up the merge conflict. The hashes mentioned above are now out-of-date, but hopefully the log is clear enough - thanks! |
The percentage indicator previously used the default colors, which was in contrast to the rest of the statusline, which used focused.
jmacdonald
force-pushed
the
main
branch
3 times, most recently
from
October 1, 2024 12:39
bd2b6df
to
6a59eae
Compare
jmacdonald
force-pushed
the
main
branch
3 times, most recently
from
November 24, 2024 16:51
cd7c041
to
f945008
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Not quite sure if there's a proper name for this; here's a screenshot of the new behavior (see the "61%" in the modeline):
I personally like this, but I don't know if everyone does. Tell me if you'd prefer this to be an option in the config rather than hard-coded!