Skip to content

Re-render sticky scroll when line numbers display mode is changed#210815

Merged
aiday-mar merged 3 commits intomicrosoft:mainfrom
timorthi:sticky-scroll-line-updates
Apr 23, 2024
Merged

Re-render sticky scroll when line numbers display mode is changed#210815
aiday-mar merged 3 commits intomicrosoft:mainfrom
timorthi:sticky-scroll-line-updates

Conversation

@timorthi
Copy link
Contributor

@timorthi timorthi commented Apr 20, 2024

Fixes #210814

This forces a re-render when the line numbers display mode is updated.

This also forces a _readConfiguration call when the display mode changes, as there is a listener registered in _readConfiguration that ensures line numbers are updated as the cursor moves while in relative display mode.

Video showing desired behavior after the changes in this PR. This video also shows smart relative lines enabled in vscode-vim, which toggles between absolute and relative lines depending on whether you are in insert or normal mode:

fixed.mp4

@aiday-mar
Copy link
Contributor

aiday-mar commented Apr 22, 2024

Hi @timorthi thank you for the PR. After looking at the code, I believe the cleanest way to solve this issue would be to refactor the code so that we have a method readConfiguration which would read the configuration, and have another method readConfigurationChange which would take in the configuration change event as a parameter. Then you could write:

readConfigurationChange(e : ConfigurationChange) {
  this.readConfiguration();
  ...
  if (e.hasChanged(EditorOption.lineNumbers)) {
      this._renderStickyScroll(0);
  }
}

In this manner the readConfigurationChange method would reuse the readConfiguration method and would add additional logic on top in the form of rerendering the widget under specific conditions.

The following check:

if (
    e.hasChanged(EditorOption.stickyScroll)
    || e.hasChanged(EditorOption.minimap)
    || e.hasChanged(EditorOption.lineHeight)
    || e.hasChanged(EditorOption.showFoldingControls)
    || e.hasChanged(EditorOption.lineNumbers)
) 

Should also be placed in the readConfigurationChange method in that case.

@timorthi
Copy link
Contributor Author

@aiday-mar Updated!

@timorthi
Copy link
Contributor Author

@microsoft-github-policy-service agree

@aiday-mar
Copy link
Contributor

Great thanks!

@aiday-mar aiday-mar enabled auto-merge (squash) April 23, 2024 07:17
@vscodenpa vscodenpa added this to the April 2024 milestone Apr 23, 2024
@aiday-mar aiday-mar merged commit 386e1cf into microsoft:main Apr 23, 2024
@timorthi timorthi deleted the sticky-scroll-line-updates branch April 23, 2024 15:57
@microsoft microsoft locked and limited conversation to collaborators Jun 7, 2024
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.

Sticky Scroll does not update when line numbers display mode is changed

4 participants