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

Introducing inner scope sticky scroll #235949

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

aiday-mar
Copy link
Contributor

@aiday-mar aiday-mar commented Dec 12, 2024

fixes #208406

@aiday-mar aiday-mar self-assigned this Dec 12, 2024
@@ -558,11 +558,16 @@ export class StickyScrollController extends Disposable implements IEditorContrib
if (arrayVisibleRanges.length !== 0) {
const fullVisibleRange = new StickyRange(arrayVisibleRanges[0].startLineNumber, arrayVisibleRanges[arrayVisibleRanges.length - 1].endLineNumber);
const candidateRanges = this._stickyLineCandidateProvider.getCandidateStickyLinesIntersecting(fullVisibleRange);
for (const range of candidateRanges) {
const reverse = true;
const finalCandidateRanges = reverse ? candidateRanges.reverse() : candidateRanges;
Copy link

@MAZ01001 MAZ01001 Feb 6, 2025

Choose a reason for hiding this comment

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

Wouldn't this (line 562 of changes) be better to write it like this:

if (reverse) candidateRanges.reverse();
// and rename all following `finalCandidateRanges` to `candidateRanges`

Since Array.reverse modifies the list in place, and thus finalCandidateRanges will equal candidateRanges either way (same reference).

Or if a copy is desired, not to modify candidateRanges, maybe something like this:

const finalCandidateRanges = reverse ? Array.from(candidateRanges, (_, i) => candidateRanges[candidateRanges.length - 1 - i]) : candidateRanges;

But I don't know for sure since I'm not familiar with the codebase...

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.

Option for sticky scroll to prioritize inner blocks
2 participants