calva

Colin P. Hill 2026-02-03T14:45:11.880149Z

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...

Colin P. Hill 2026-02-04T18:59:09.283069Z

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.

jramosg 2026-02-04T22:00:49.262209Z

Hello! could you try with this version?

jramosg 2026-02-04T22:01:38.209479Z

jramosg 2026-02-04T22:10:02.456129Z

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

pez 2026-02-05T07:52:10.779149Z

🤘

jramosg 2026-02-06T08:09:07.074329Z

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

jramosg 2026-02-06T08:13:34.496669Z

jramosg 2026-02-06T11:32:32.166179Z

this one uses sync insertLineWithIndent as suggested in PR

pez 2026-02-03T16:30:08.514959Z

Not good! What’s your config for Calva indentation engine?

Colin P. Hill 2026-02-03T16:46:35.781829Z

New engine enabled

pez 2026-02-03T16:52:09.991859Z

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.

Colin P. Hill 2026-02-03T19:26:54.073169Z

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.

pez 2026-02-03T19:30:18.185629Z

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.

2026-02-03T22:29:30.602979Z

@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?

jramosg 2026-02-05T08:52:10.259319Z

I've opened a PR with the possible fix https://github.com/BetterThanTomorrow/calva/pull/3034 so we can discuss about it there too

🙏 1
Colin P. Hill 2026-02-05T19:41:33.640099Z

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.

pez 2026-02-05T19:43:01.285879Z

Strange that it skips indenting in that case. But better than garbling the text!

Colin P. Hill 2026-02-05T19:43:53.327209Z

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.

jramosg 2026-02-05T20:02:59.535809Z

Umm, strange, in the tests I did I would say it was indenting but I will try again

🤔 1
Colin P. Hill 2026-02-05T20:04:10.476639Z

Dunno if your computer is just faster than mine or what. Maybe a tool like AHK would help repro?

jramosg 2026-02-05T20:09:24.066319Z

Can you share a video please? 🙂

Colin P. Hill 2026-02-05T20:10:09.618389Z

I... don't think my employer would be too happy about that

pez 2026-02-05T20:20:10.031649Z

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.

➕ 1
jramosg 2026-02-05T21:45:27.541739Z

okey, if you agree I’ll merge tomorrow morning and lets see if I can repro and fix it

pez 2026-02-05T21:56:05.441699Z

You have to run very fast! https://www.youtube.com/shorts/RiadD4KvGEI

😂 1
jramosg 2026-02-06T06:43:54.233849Z

merged into dev branch

🤘 1