Dash Separated / Kebab Case Selection Too Inclusive

Typically on Mac, double clicking a dash separated “word” ( like-this-example ) will only select the clicked segment up until a dash. (Double click example and you’d get like-this-example with the bold text showing the selection.)

Example in TextEdit: Screen Recording 2025-12-19 at 10.mp4 - Droplr

In CodeMirror 5, that’s how it works: Screen Recording 2025-12-19 at 10.mp4 - Droplr

But in CodeMirror 6, the whole dash separated word is selected: Screen Recording 2025-12-19 at 10.mp4 - Droplr

If I’m understanding this question ( Can I change what constitutes a "word" in terms of selection? ) correctly, then this selection functionality is due to the CSS languages containing wordChar of -.

This is unexpected for some of our users. Is there a simple way to change that or does it require making your own CSS LRLanguage (and any CSS based language) to override the wordChar option?

And if you do override the wordChar option, what other features does that affect?

There wasn’t, but that wouldn’t do, so now there is.

Anything that works with words, like by-word cursor motion, will be affected by this.

(It’s not always necessary to change something as soon as a user complains. Being able to select entire identifiers by double clicking is really quite convenient.)

1 Like

Actually, ignore that patch I linked. It is very broken. With @codemirror/state 6.5.3 you can now add a higher-precedence bit of language data (cssLanguage.data.of({wordChars: ""})) to your configuration to override the default word characters.

1 Like

Thanks for the quick response & solution! That’s a much better way to patch this. We’ll do some testing and see if we want to offer this by default or via an option for users.