Skip to content

Commit 1136362

Browse files
committed
feat: early return applysmartquotes if entered char is already desired quote
1 parent e5888d4 commit 1136362

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/smartQuotes.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ export const applySmartQuotes = (range, config, char, target, cursorOffset) => {
4444
return
4545
}
4646

47+
const {quotes, singleQuotes} = config
48+
if (char === quotes[0] || char === quotes[1] || char === singleQuotes[0] || char === singleQuotes[1]) {
49+
return
50+
}
51+
4752
const offset = range.startOffset
4853
const textArr = [...range.startContainer.textContent]
49-
const {quotes, singleQuotes} = config
5054
let newTextNode
5155

5256
if (shouldBeClosingQuote(textArr, offset - 2)) {

0 commit comments

Comments
 (0)