rescript-vscode icon indicating copy to clipboard operation
rescript-vscode copied to clipboard

Editor jumps 200 lines below when formatting on save

Open DZakh opened this issue 5 months ago • 8 comments

I get the behavior with beta.5 and 1.64.0

Any change in https://github.com/DZakh/sury Sury.res which requires a formatting update.

DZakh avatar Aug 12 '25 06:08 DZakh

Do you have the GitLens extension enabled? And if so, does the problem go away once you disable it and reload VS code?

One of my colleagues was having the same issue as you where his cursor would jump on save and we narrowed it down to a recent update in GitLens.

mediremi avatar Aug 16 '25 11:08 mediremi

I think I do. I'll try to remove it

DZakh avatar Aug 16 '25 12:08 DZakh

In F#, we solved this problem by attaching the cursor to an AST node. (Similar to how comments works)

You pass it a cursor position and get the position back after formatting. Then the editor could scroll to that position if necessary.

nojaf avatar Aug 18 '25 08:08 nojaf

Still jumps. Specifically in the file https://github.com/DZakh/sury/blob/main/packages/sury/src/Sury.res

DZakh avatar Aug 23 '25 13:08 DZakh

Works good after disabling the option

Image

DZakh avatar Sep 03 '25 09:09 DZakh

That is... weird.

zth avatar Sep 03 '25 10:09 zth

I have 6500 lines file with almost every ReScript feature. Probably one of them causes the problem 🤔

DZakh avatar Sep 03 '25 10:09 DZakh

Oh right, something is probably messing up the locs in the code lens. Feels like something that should be pretty easy to track down. Good that we have the reproduction, hopefully someone can take a look at this.

zth avatar Sep 03 '25 10:09 zth