Triggering editor.action.commentLine on empty lines produces odd indentation in certain places
I've noticed there are a few situations where triggering editor.action.commentLine on an empty line produces odd indentation.
In the following clip, commentLine inserts the ;; a column before where it should be, and produces an extra space after them:
In this clip, I do the same but also hit tab after finishing the comment, showing that Calva correctly reindents the comment to the correct column, albeit with an extra space after the ;;:
This has been a fairly regular annoyance for a while, it would be great if it could be resolved!
Thanks for the report! 🙏
It is a bit hard to follow screen recordings like this. Usually it is easier with text examples. But I think I see most of what you refer to.
I don't know how to do anything about this, but that doesn't mean it can't be done. The comment characters for this command is defined here: https://github.com/BetterThanTomorrow/calva/blob/29205916c0c9fb329fd5d4ce9cd3be9fc67dfdb0/language-configuration.json#L3
It could be that Calva does something when the document changes, like the on-type formatter or something. https://github.com/BetterThanTomorrow/calva/blob/6a41212e3a4c332c5e3f7dec6040df86b89af13f/src/calva-fmt/src/providers/ontype_formatter.ts#L22
Running it in the debugger with breakpoints at strategic places, may reveal something.
Well I haven't managed to find the source of the problem, but I think I've managed to eliminate a class of potential causes: the problem still occurs with the entirety of extension.ts/activate commented out. That rules out the on-type formatter, and probably a bunch of other things too.
Thoughts on what the potential remaining causes might be? Or is this maybe a case of something missing from the on-type formatter?
I have no real idea what to do about it.
I've done a little more digging and found some interesting things:
- The issue occurs with all extensions disabled (i.e.
code --disable-extensions) - The issue DOES NOT occur in unsaved files
- The placement of the comment seems to depend on the language mode. For example, with Python the comment is placed at the beginning of the line regardless of the indent column.
This leads me to believe that the root cause of the issue lies in the definition of the clojure language mode, which is still available even with Calva disabled. I'm a little out of my depth here, but do you have any idea where the Clojure language definition could come from, if not from Calva? Or could it still loaded from Calva even when the Calva extension is disabled?
Calva overrides the default language definition. But it was based on the default so both could contain the same issue.
I don't think Calva's version is at play when Calva is disabled. The dev tools console warns when Calva's definition takes over. Or used to at least.