Hi @marijn, I have been working on a Markdown editor and recently discovered this issue, while it might be design, I would like to hear your thoughts.
Let’s say I am setting up the editor like this:
import {basicSetup, EditorView} from "codemirror"
import {markdown, markdownLanguage} from "@codemirror/lang-markdown"
import {languages} from "@codemirror/language-data"
let view = new EditorView({
doc: "Hello\n\n```javascript\nlet x = 'y'\n```",
extensions: [
basicSetup,
markdown({codeLanguages: languages}),
markdownLanguage.data.of({
closeBrackets: {
brackets: [
// Default
'(', '[', '{', '\'', '"',
// Custom
'`', '*', '_',
],
}}),
],
parent: document.body
})
I added “`” to closeBrackets
, so that when I insert a backtick, it automatically closes as two backticks.
It works great and closes only before non-whitespace characters, for most cases. However, I found some exceptions.
For example (| is the caret position):
`|+
If the caret is before a plus sign and I insert a backtick, it closes as two backticks.
``|+
However, the behavior is not quite consistent, if I insert a (
instead of backtick, it won’t close it.
I am quite confused by what I’ve observed and would like to understand if it’s desired.
The code snippet can be used to reproduce the issue on Try CodeMirror.
Could you please take a look?
Thanks!