diff --git a/codejar.ts b/codejar.ts index ba92a60..ec57842 100644 --- a/codejar.ts +++ b/codejar.ts @@ -249,12 +249,14 @@ export function CodeJar(editor: HTMLElement, highlight: (e: HTMLElement) => void const open = `([{'"` const close = `)]}'"` const codeAfter = afterCursor() - if (close.includes(event.key) && codeAfter.substr(0, 1) === event.key) { + const codeBefore = beforeCursor() + const escapeCharacter = `'"`.includes(event.key) && codeBefore.substr(codeBefore.length-1) !== "\\" + if (close.includes(event.key) && escapeCharacter && codeAfter.substr(0, 1) === event.key) { const pos = save() preventDefault(event) pos.start = ++pos.end restore(pos) - } else if (open.includes(event.key)) { + } else if (open.includes(event.key) && escapeCharacter) { const pos = save() preventDefault(event) const text = event.key + close[open.indexOf(event.key)]