Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

WIP fix #61 insert quote #179

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix #61 insert quote
  • Loading branch information
Dufgui committed Oct 15, 2024
commit e6cad4917c03883b220e74b2f8be547b079d49e1
10 changes: 8 additions & 2 deletions addon/data-load.js
Original file line number Diff line number Diff line change
@@ -1280,9 +1280,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");
}
}