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

Make line numbers relative #1

Closed
wants to merge 2 commits into from

Conversation

jannes
Copy link

@jannes jannes commented Dec 2, 2020

This makes the displayed line numbers relative to current line.
The current line number will also be displayed.
This is the same behavior as Vim hybrid line numbers (:set number relativenumber).

I find this the most useful when using Vim.
We could also add a build option to let the user choose between absolute and relative.

reference for implementation:
codemirror/codemirror5#4116

@shantanugoel
Copy link
Owner

Awesome work, @jannes 👍 It works perfectly. Could you please see if you could add the option to choose between absolute and relative. If you'd like to do that as a separate PR, that's ok too (Let me know if that's the case).

@jannes
Copy link
Author

jannes commented Dec 3, 2020

I'll have a look, so you think just having to different npm commands to build one or the other would be good?
E.g npm run dist-absolute, npm run dist-relative

@shantanugoel
Copy link
Owner

I was thinking of more like adding a setting using joplin.settings API that users could flip on/off. But in case it looks time consuming to do, different npm commands is ok to do for now and I can add the settings myself once I get a breather from work.

@jannes
Copy link
Author

jannes commented Dec 3, 2020

No, I agree that would be the nicest, but are you sure that this is already possible with the current plugin system?
If so, I would have a look at this the coming days

Edit:
I don't think it is possible yet to have subsettings for plugins.
But we can add an extra menu item 'Toggle absolute/relative linenumbers' in the 'View' menu.
What do you think?

@shantanugoel
Copy link
Owner

shantanugoel commented Dec 3, 2020

But we can add an extra menu item 'Toggle absolute/relative linenumbers' in the 'View' menu.

Yes, this should be good.

@jannes
Copy link
Author

jannes commented Dec 9, 2020

Still haven't found the time to implement the setting.

But I notice that the relative line numbers do not work consistently,
after some time of having Joplin open it stops working and just uses the absolute numbering.
Can you confirm this behavior?

It seems like the event handler for 'cursorActivity' is overriden/removed somehow,
can not explain this otherwise.

@shantanugoel
Copy link
Owner

Hmm, I haven't seen that behavior. My instance has been open for many days but it's still showing relative numbers. Will keep an eye out for it.

@jannes jannes closed this Aug 13, 2024
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.

None yet

2 participants