microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.74k stars 28.17k forks source link

[folidng] python ranges unfold when the folding ranges are coming late #165266

Open fredericomattos opened 1 year ago

fredericomattos commented 1 year ago

Pylance language server 2022.11.10 (pyright 4e50162d) Python version 3.10 Python platform Windows Pylance v2022.11.10

https://user-images.githubusercontent.com/58320500/199490941-be69bd5e-d3a8-484f-a8c5-315cad713db7.mp4

This is the part of the code that is automatically expanded when I open VSCode without me clicking to expand:

to_list = [
    "/international/africa/africa-cup-of-nations/",
    "/international/africa/caf-champions-league/",
    "/international/africa/caf-confederation-cup/",
    "/international/africa/caf-super-cup/",
    "/international/africa/wc-qualifying-africa/",
    "/international/asia/afc-champions-league/",
    "/international/asia/wc-qualifying-asia/",
    "/international/europe/baltic-cup/",
    "/international/europe/european-championship-qualification/",
    "/international/europe/european-championships/",
    "/international/europe/uefa-champions-league/",
    "/international/europe/uefa-cup/",
    "/international/europe/uefa-europa-conference-league/",
    "/international/europe/uefa-nations-league/",
    "/international/europe/uefa-super-cup/",
    "/international/europe/uefa-youth-league/",
    "/international/europe/wc-qualifying-europe/",
    "/international/nc-america/concacaf-champions-league/",
    "/international/nc-america/concacaf-gold-cup/",
    "/international/nc-america/concacaf-nations-league/",
    "/international/nc-america/wc-qualifying-concacaf/",
    "/international/south-america/copa-america/",
    "/international/south-america/copa-libertadores/",
    "/international/south-america/copa-sudamericana/",
    "/international/south-america/recopa-sudamericana/",
    "/international/south-america/wc-qualifying-south-america/",
    "/international/world/fifa-club-world-cup/",
    "/international/world/world-cup/",
    "/international/world/joan-gamper-trophy/",
    "/international/world/olympics/",
    "/national/argentina/copa-argentina/",
    "/national/argentina/primera-division/",
    "/national/australia/a-league/",
    "/national/australia/ffa-cup/",
    "/national/austria/bundesliga/",
    "/national/austria/ofb-stiegl-cup/",
    "/national/belarus/premier-league/",
    "/national/belgium/beker-van-belgie/",
    "/national/belgium/pro-league/",
    '/national/belgium/super-cup/',
    "/national/brazil/copa-do-brasil/",
    "/national/brazil/liga-do-nordeste/",
    "/national/brazil/mineiro-1/",
    "/national/brazil/paulista-a1/",
    "/national/brazil/serie-a/",
    "/national/brazil/serie-b/",
    "/national/brazil/supercopa-do-brasil/",
    "/national/chile/copa-chile/",
    "/national/chile/primera-division/",
    "/national/chile/promotion-play-off/",
    "/national/china-pr/csl/",
    "/national/colombia/primera-a/",
    "/national/colombia/super-cup/",
    "/national/croatia/1-hnl/",
    "/national/croatia/hr-nogometni-cup/",
    "/national/denmark/dbu-pokalen/",
    "/national/denmark/superliga/",
    "/national/england/championship/",
    "/national/england/community-shield/",
    "/national/england/fa-cup/",
    "/national/england/football-league-trophy/",
    "/national/england/league-cup/",
    "/national/england/premier-league/",
    "/national/france/coupe-de-france/",
    "/national/france/coupe-de-la-ligue/",
    "/national/france/ligue-1/",
    "/national/france/ligue-2/",
    "/national/france/super-cup/",
    "/national/germany/2-bundesliga/",
    "/national/germany/3-liga/",
    "/national/germany/bundesliga/",
    "/national/germany/dfb-pokal/",
    "/national/germany/super-cup/",
    "/national/greece/super-league/",
    "/national/italy/coppa-italia/",
    "/national/italy/serie-a/",
    "/national/italy/serie-b/",
    "/national/italy/super-cup/",
    "/national/japan/emperor-cup/",
    "/national/japan/j-league-cup/",
    "/national/japan/j1-league/",
    "/national/japan/super-cup/",
    "/national/korea-republic/k-league-classic/",
    "/national/mexico/primera-division/",
    "/national/netherlands/eerste-divisie/",
    "/national/netherlands/eredivisie/",
    "/national/netherlands/knvb-beker/",
    "/national/netherlands/nacompetitie/",
    "/national/norway/eliteserien/",
    "/national/paraguay/division-profesional/",
    "/national/poland/ekstraklasa/",
    "/national/portugal/league-cup/",
    "/national/portugal/portuguese-liga-/",
    "/national/portugal/taca-de-portugal/",
    "/national/romania/liga-i/",
    "/national/romania/supercupa/",
    "/national/russia/cup/",
    "/national/russia/premier-league/",
    "/national/russia/super-cup/",
    "/national/scotland/premier-league/",
    "/national/scotland/scottish-cup/",
    "/national/spain/copa-del-rey/",
    "/national/spain/primera-division/",
    "/national/spain/segunda-division/",
    "/national/spain/super-cup/",
    "/national/sweden/allsvenskan/",
    "/national/sweden/svenska-cupen/",
    "/national/switzerland/play-off--out/",
    "/national/switzerland/super-league/",
    "/national/turkey/cup/",
    "/national/turkey/super-cup/",
    "/national/turkey/super-lig/",
    "/national/ukraine/premier-league/",
    "/national/united-states/mls/",
    "/national/egypt/premier-league/",
    "/national/united-states/us-open-cup/"
]
to_list_replaces = [
    code.replace('/international', '').replace('/national', '') for code in to_list
]
rchiodo commented 1 year ago

My guess is that when VS code opens, it provides the folding ranges. Then when pylance loads, it updates the allowed folding ranges to include the list.

This seems correct because if you just close and reopen the file, it remembers them.

Yeah, it seems the unfolding happens before the pylance server loads, so VS code is doing the unfolding. When pylance loads again it does provide the folding ranges back, so theoretically VS code should refold the entries:

This seems like a bug in VS code.

aeschli commented 1 year ago

The pylance folding provider includes the closing ] in the folding range. Is that intended?

rchiodo commented 1 year ago

The pylance folding provider includes the closing ] in the folding range. Is that intended?

AFAIK, yes. Is that causing the problem?

aeschli commented 1 year ago

While the pylance extension is starting, the indent folding provider is used, and it has smaller ranges. Currently we interpret this as a user edit and unfold the ranges.

It's tricky, and ideally we would not unfold in this case.

rtdietrich commented 6 months ago

I see that this bug has been open for > 12 months. Since I am affected by it myself, my question. Do we have a change that this will be fixed soon?