codemirror-plugin icon indicating copy to clipboard operation
codemirror-plugin copied to clipboard

CodeMirror 5 + Sublime Text Key Bindings + Multiple Selections =

Open chriscoyier opened this issue 4 years ago • 2 comments

So Command-D in "normal" emmet does outward-expansion. But in CodeMirror, if you turn on the official Sublime Text bindings:

https://codemirror.net/demo/sublime.html

Then Command-D gets replaced with "select next occurrence" (selectNextOccurrence).

Because CodeMirror supports multiple selections/multiple cursors, that means you don't just have the original selection, but it keeps adding to the selection.

That's all fine, and so far working as expected:

https://user-images.githubusercontent.com/69156/122927775-0e759a80-d31e-11eb-8941-9573bd90cb8f.mp4

But that's without Emmet.

I would test it here, but this demo doesn't have Sublime Text bindings on:

https://download.emmet.io/codemirror/index.html

On CodePen, we do (you have to turn on Sublime Text bindinds, and Emmet, in Editor Preferences).

When BOTH are active, in HTML specifically, something gets funky with line positions. You can see here:

https://user-images.githubusercontent.com/69156/122928052-58f71700-d31e-11eb-916d-60cb0ad73cb8.mp4

It looks like maybe Emmet's tag-matching thing is catching the second-and-beyond selection?

chriscoyier avatar Jun 22 '21 12:06 chriscoyier

Noting that I now DON'T think it's related to those sublime text bindings. I can make it happen right here:

https://download.emmet.io/codemirror/index.html

See HTML like this:

  <body>
    <Chart />
    <div class=""></div>
    <Chart />
    <div class=""></div>
    <Chart />
    <div class=""></div>
  </body>

The multiple cursors + return + type screws it up.

https://user-images.githubusercontent.com/69156/130701312-5c15b566-ee71-439d-8495-783c5d884f5e.mp4

chriscoyier avatar Aug 24 '21 23:08 chriscoyier

Hmm, that's look really weird. Will check it out

sergeche avatar Aug 25 '21 18:08 sergeche