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

Relative Line Number support #12055

Closed
wants to merge 21 commits into from
Closed

Relative Line Number support #12055

wants to merge 21 commits into from

Conversation

alfanick
Copy link

Adds support for vim-style relative line numbers.

Useful for vim motion plugins, replacing extension "Relative Line Numbers" by extr0py.

  • word-wrapping aware
  • adds editor.relativeLineNumbers option (changeable without restart), default to false
  • current line is absolute, others are relative (behaviour of hybrid relative numbers in vim)

@msftclas
Copy link

Hi @alfanick, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla.microsoft.com.

TTYL, MSBOT;

@msftclas
Copy link

@alfanick, Thanks for signing the contribution license agreement so quickly! Actual humans will now validate the agreement and then evaluate the PR.

Thanks, MSBOT;

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 61.106% when pulling f7fcfc3 on alfanick:master into 50bb7aa on Microsoft:master.

@alfanick
Copy link
Author

alfanick commented Sep 16, 2016

I've made some more aggresive optimizations on alfanick/vscode/optimized-relative-numbers – I'm assuming that there is no need for rendering line numbers on modelLinesInserted/modelLinesDeleted as cursorPositionChanged is always called with these events, also no need for rendering with every modelLineChanged unless wordWrapping is enabled (this is only case when line can break and change numbering).

I'm not really expert on VSCode flow, so these optimizations actually may break smth, but they work for me – the pull request does not brake anything, where branch optimized-relative-numbers does not brake anything either, but needs thorough code review (I can merge optimized-relative-numbers into alfanick/vscode/master if requested).

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.01%) to 61.148% when pulling 9a7849c on alfanick:master into 179f86f on Microsoft:master.

Copy link
Member

@alexdima alexdima left a comment

Choose a reason for hiding this comment

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

Thank you!

The change gets correctly the adding an option code, and when to update/re-render the line numbers.

However, it appears to me that it breaks the old behaviour of non-relative line numbers completely.

Please address these comments, and resubmit the PR, as it appears many unnecessary commits have made their way into this PR.

Looking forward to your changes! 👍

return false;
}

this._currentLineNumber = modelPosition.lineNumber;
Copy link
Member

@alexdima alexdima Sep 21, 2016

Choose a reason for hiding this comment

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

In the case where this._relativeLineNumbers is false, this._currentLineNumber should still be assigned such that this._currentLineNumber always has a good value.

It is possible that the relativeLineNumbers option changes at runtime and in that case we'd want this._currentLineNumber to be up-to-date.

let relativeLineNumber = position.lineNumber;

if (position.column === 1) {
if (this._relativeLineNumbers) {
Copy link
Member

Choose a reason for hiding this comment

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

The test if (this._relativeLineNumbers) should be the first thing done here before doing any position conversions. All the new rendering code should go in this if. All the old rendering code should be maintained in an else branch. As it looks right now, regular line number rendering appears to be broken.

@@ -3,6 +3,7 @@ npm-debug.log
Thumbs.db
node_modules/
.build/
.vscode/.browse.VC*
Copy link
Member

Choose a reason for hiding this comment

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

Please remove this one, you can use .git/info/exclude for it

@alexdima alexdima added this to the September 2016 milestone Sep 21, 2016
@alexdima
Copy link
Member

@alfanick Please let me know if this is something you want to look into, otherwise I will pick it up, as it is something we want to get done in Sept (i.e. by Friday the latest). Then I need to expose extension host API for it.

@alexdima
Copy link
Member

I've implemented this in 13bbe32

@alexdima alexdima closed this Sep 26, 2016
@github-actions github-actions bot locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants