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

Stick Scroll sticks python function's decorator line instead of the declaration line #157180

Closed
lephuongbg opened this issue Aug 5, 2022 · 17 comments · Fixed by #157466
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-sticky-scroll insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@lephuongbg
Copy link

Does this issue occur when all extensions are disabled?: Yes/No

  • VS Code Version: 1.70.0
  • OS Version: Windows 11

Steps to Reproduce:

  1. Enable sticky scroll
  2. Scroll through a python function with decorator

The function:
image

When the view is scrolled, sticky line should show the definition instead of the decorator. This is what it's like currently:
image

@nicok1
Copy link

nicok1 commented Aug 5, 2022

Thank you for creating this topic. I have the same problem with all kinds of Spring Boot annotations. One function is sometimes also annotated with multiple annotations, which should also be taken into account.

@pxlrbt
Copy link

pxlrbt commented Aug 5, 2022

Same for PHP Docblocks or Attributes.

class Kernel extends ConsoleKernel
{
    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {

shows

Bildschirmfoto 2022-08-05 um 12 23 03

instead of

Bildschirmfoto 2022-08-05 um 12 23 28

@IllusionMH
Copy link
Contributor

It this issue specific to language or decorators? If yes, I'll create separate issue

"Similar" problems can be noticed in Java files where sticky scroll picks start of javadoc comment instead of class/method declarations
image

@pxlrbt
Copy link

pxlrbt commented Aug 5, 2022

I don't have any issues with docblocks in JS. But apparently a lot of other langauges.

@IllusionMH
Copy link
Contributor

Looks like same problem with decorators is reproducible in JS/TS, but not with comments (as in Java above)
image

@RadsammyT
Copy link

RadsammyT commented Aug 5, 2022

This also happens with rust doc blocks, either with the triple slash (///) or the usual doc block ( /** */)

/// All elements of the vector are set to a random number from 0 to the length of the vector (Exclusive)
/// # Example
/// ```
/// vec = shuffle(&mut vec).to_vec();
/// ```
fn shuffle(v: &mut Vec<i32>) -> Vec<i32>{
    let test = v.len() as i32;
    for i in 0..v.len() as i32 {
        v[i as usize] = rand::thread_rng().gen_range(0..test);
    }
    return v.to_vec();
}

RRXxtc2TFc

What is interesting to note is that C++ (and very likely C) is not affected by this.

    /**
     * @brief Returns an int based on user input
     * 
     * @param prompt 
     * @return int 
     */
    int readI32(std::string prompt) {
        int x;
        std::cout << prompt;
        try {
            std::cin >> x;
        } catch(std::exception e) {
            std::cout << "Invalid input" << std::endl;
            return readI32(prompt);
        }
        return x;
    }

TA60M4Dg28

@dfarley1
Copy link

dfarley1 commented Aug 5, 2022

This is happening in C code where the function declarations are split over multiple lines as well:
image
image
(yes I realize I wrote invalid code 🙃 )

@aiday-mar
Copy link
Contributor

Hi thanks for all your feedback. I will be looking into all these issues.

@TheColorRed
Copy link

TheColorRed commented Aug 8, 2022

I am seeing this with TypeScript decorators as well, so it looks like it is most/all languages.

@alexdima alexdima added the bug Issue identified by VS Code Team member as probable bug label Aug 8, 2022
@alexdima
Copy link
Member

alexdima commented Aug 8, 2022

This might be improved if we would have a custom sticky ranges provider. A language server might tweak the results it would return from a sticky ranges provider to exclude decorators/comments/etc. Also related #157165

@alexdima
Copy link
Member

alexdima commented Aug 8, 2022

Another example for C# from #157293

When using the new Sticky Scroll with a .NET API project, scrolling in a controller will only show any attributes as the "sticky" heading - [ApiController] - [HttpPost], etc.
image
image

@paulojcdev
Copy link

paulojcdev commented Aug 9, 2022

Hi,
Similar issue happens with AL language,

Sticky:
image

expected:
image

procedure:
image

Thanks for this feature!

@aiday-mar
Copy link
Contributor

aiday-mar commented Aug 10, 2022

Thank you for all the feedback. This should be fixed by #157466 with @DingWeizhe's contribution

New behavior:

sticky-scroll-python

sticky-scroll-spring

sticky-scroll-php

sticky-scroll-rust

sticky-scroll-c

sticky-scroll-cs

@Grueslayer
Copy link

@aiday-mar This seems not to be fixed for AL as posted by @paulojcdev in #157180 (comment) some comments before you commited the fix.

@aiday-mar
Copy link
Contributor

aiday-mar commented Aug 19, 2022

Hi thanks for the feedback. Are you using the Insiders VSCode version? If you are on the stable version (which comes out once per month) you will not yet see the change until the next release. If you are on the Insiders version, are you using an extension which provides a language server for AL? The sticky scroll depends on this. If you are, what extension are you using? I will test on my computer.

@Grueslayer
Copy link

I’m on insiders. AL comes from MS and uses a language server. https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al

@DonJayamanne
Copy link
Contributor

Verified, however I now run into another issue, not sure if its related though #159118

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug editor-sticky-scroll insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet