Is default codemirror mapped to emacs keys?

Hi, I’m using a fairly basic installation of code mirror:

    const sqlEditor = CodeMirror.fromTextArea(sqlTextArea, { mode: "sql", theme: "base16-light", lineWrapping: true, autofocus: true, viewportMargin: Infinity });

However, on my windows machine, with a Chrome browser, I can’t use the standard keyboard shortcuts for the text, such as ctrl-a to select all, even ctrl-c and ctrl-v to copy and paste. ctrl-a moves the cursor to the beginning of the line (and ctrl-v to the end), which tells me that perhaps emacs binding are the default?

I have played around with other codemirror on other sites, such as https://codemirror.net/demo/theme.html and ctrl-a does ‘select all,’ like I expect it to.

What am I doing wrong?

No, it’s not, and the configuration you show won’t do that either, unless it somehow incorrectly detects that it is on macOS (but I don’t see why it would do that on one site but not on another in a single browser).

This is very strange. I just tried on firefox and ctrl-a works like it is supposed to. On Chrome and Edge, it doesn’t.

As I said, as far as I know, I haven’t done anything fancy with firefox, except connect it to vue:

const sqlEditor = CodeMirror.fromTextArea(sqlTextArea, { mode: "sql", theme: "base16-light", lineWrapping: true, autofocus: true, viewportMargin: Infinity });

sqlEditor.on('change', function (e) { app.sqlText = sqlEditor.getValue(); });

Since vue can’t monitor the changing text in codemirror, I watch it and update my vue variable. I don’t see how this changes the keymaps.

You can see the result here:

It definitely doesn’t.

My Chromium (on Linux) doesn’t have the problem you describe (ctrl-a does select all). Have you checked if you have any odd browser plugins running?

It just became even stranger. I checked my extensions and they are mostly reputable, google docs, webex meetings, etc. What’s more, I tested on two other windows, Chrome computers (not mine, so different plugins) and they both had exactly the same issue.

Chrome on mac worked perfectly.

Are you using version 5.59.1?

In the code, I see CodeMirror.vesrion = "5.59.0";
I just switched it out for the latest: 5.59.1 and all of a sudden, the problem is gone!
Not sure what was causing it, but my problem seems to be resolved now.

Thanks for you help!

I guess this was another side effect of #6532.

1 Like