I keep having an issue with the cursor jumping around as I type, seemingly due to autoformatting. E.g., when I try to type
(comment
:rcf)
I wind up with
(comment
rcf:)
because the indentation takes a moment to appear, generally happening right after I type the colon, and when it does it pushes my cursor back to the beginning of the line.
Anyone have any idea what I may have misconfigured here? It wasn't like this on my last machine...cljfmt seems to have a similar race with different results. It also seems to be slightly slower — bigger window for the race. (comment<RET>asdf now yields
(comment
asdf)
if I'm quick enough, simply not indenting at all. A more graceful degradation, I suppose.Hello! could you try with this version?
I introduced a fn that returns TextEdit objects when calculating indents on edit. I cannot reproduce the issue easily so I really apreciate if you could install this vsix and try it
🤘
I've this new approach where I use a vs command, let's see if it fixes the no indentation problem https://github.com/BetterThanTomorrow/calva/pull/3037
this one uses sync insertLineWithIndent as suggested in PR
Not good! What’s your config for Calva indentation engine?
New engine enabled
Extra strange. That’s supposed to be really quick. Maybe there’s another extension interfering… There is Extension Bisect, which I don’t know if it let’s you isolate Calva and bisect the others… Otherwise, disable all other extensions and see how Calva behaves. At least that will tell us if Calva needs any help in misbehaving or not.
Didn't know about Extension Bisect, neat! What I found from bisecting is... any reload fixes it, more or less. I can still reproduce it on a freshly reloaded editor, but only if I'm extremely fast. E.g., typing (comment<RET>asdf can still result in
(comment
sdfa)
but I'm unable to type : quickly enough to make it happen that way. Disabling all extensions but Calva makes the time window for running into this even smaller, but it doesn't disappear. So, best guess: Other extensions had enough of their own edit event handlers (which may have a leak somewhere) that it slowed down Calva's formatting, increasing the opportunity for a race condition that may in theory always be there.I think @phill is the one that has the most complete mental model of the edit queue. Let’s see if he has any idea.
@dorandraco I think you are on to something. There is probably a race. By the look of things, in format.ts, indentPosition takes a measurement, awaits a promise (during which time VS Code might execute a key you pressed), queues up an async edit based in part on the old measurement, awaits a promise (during which time etc etc), and finally positions the cursor at a pre-planned spot. However, I am not absolutely sure that indentPosition is relevant to your situation. Does it work better if you switch from the new formatter to cljfmt?
I've opened a PR with the possible fix https://github.com/BetterThanTomorrow/calva/pull/3034 so we can discuss about it there too
That does seem to have fixed it! On that version, on both identation engines, if I manage to hit a key before it indents, it just...doesn't indent. But it no longer jumbles the order of my keystrokes.
Strange that it skips indenting in that case. But better than garbling the text!
Yeah, easy to work around by just hitting the autoformat hotkey. I'll report back if I notice any issues if/when my editor starts to chug again, but this is at the very least an improvement.
Umm, strange, in the tests I did I would say it was indenting but I will try again
Dunno if your computer is just faster than mine or what. Maybe a tool like AHK would help repro?
Can you share a video please? 🙂
I... don't think my employer would be too happy about that
I can repro the new problem using the PR build, @jonurnieta. But I have to really try many times. I say ship it! 🚢 It is much better than the garbling. If it would happen, you just press tab, and that’s it.
okey, if you agree I’ll merge tomorrow morning and lets see if I can repro and fix it
You have to run very fast! https://www.youtube.com/shorts/RiadD4KvGEI
merged into dev branch