toggleComment vs. selection and history


I’m very much enjoying using codemirror to implement a SQL editor (thanks a lot!), but am having issues with the “comment” addon.

I added some extra keys bound to the toggleComment command, which works well for single line comments (whether or not some text is selected).

However, when I select multiple lines, these lines are well commented/uncommented (as single line comments btw not block comments), and:

  • the selection is lost (and cursor goes to the very end of the editor)
  • I cannot undo this operation (with e.g. Ctrl-Z)

Is this a known issue? (Could not find here on in the larger internet, and also could not find a simple demo with this “comment” addon, is there any out there?)

Thanks in advance for your help!


toggleComment with multiple lines selected seems to work fine for me (selection is where it should be, undo works). Can you show a minimal setup that shows the problem?

Thank you for this quick answer!
I’ll try to have a more minimal setup and reproduce.
Is there any live demo around that you would know of with “comment” addon and “sql” mode?