Skip to content

Commit

Permalink
fix #61 insert quote
Browse files Browse the repository at this point in the history
  • Loading branch information
Dufgui authored and dufoli committed Nov 1, 2024
1 parent 5f8b92c commit 9a95b06
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions addon/data-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -1337,9 +1337,15 @@ export class Editor extends React.Component {
if (selectionStart != selectionEnd) {
model.editor.setRangeText(closeChar, selectionEnd + 1, selectionEnd + 1, "preserve");
} else if (
// If parenthesis, brace or bracket
(e.key !== "'" && e.key !== "\"")
|| (selectionEnd + 1 < model.editor.value.length && /[\w|\s]/.test(model.editor.value.substring(selectionEnd + 1, selectionEnd + 2)))
|| selectionEnd + 1 === model.editor.value.length) {
// Or one side is a whitespace or a carriage return
|| (selectionEnd + 1 < model.editor.value.length && /[\n|\s]/.test(model.editor.value.substring(selectionEnd + 1, selectionEnd + 2)))
|| (selectionEnd > 0 && /[\n|\s]/.test(model.editor.value.substring(selectionEnd - 1, selectionEnd)))
// Or end of document
|| selectionEnd + 1 === model.editor.value.length
// Or start of document
|| selectionEnd === 0) {
model.editor.setRangeText(closeChar, selectionEnd + 1, selectionEnd + 1, "preserve");
}
}
Expand Down

0 comments on commit 9a95b06

Please sign in to comment.