Merge branch 'master' into fix/import-query

This commit is contained in:
Michael Drury 2025-03-07 16:01:03 +00:00 committed by GitHub
commit d13c1e55f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 18 additions and 5 deletions

View File

@ -280,16 +280,15 @@
EditorView.inputHandler.of((view, from, to, insert) => {
if (jsBindingWrapping && insert === "$") {
let { text } = view.state.doc.lineAt(from)
const left = from ? text.substring(0, from) : ""
const right = to ? text.substring(to) : ""
const wrap = !left.includes('$("') || !right.includes('")')
const wrap =
(!left.includes('$("') || !right.includes('")')) &&
!(left.includes("`") && right.includes("`"))
const anchor = from + (wrap ? 3 : 1)
const tr = view.state.update(
{
changes: [{ from, insert: wrap ? '$("")' : "$" }],
selection: {
anchor: from + (wrap ? 3 : 1),
},
},
{
scrollIntoView: true,
@ -297,6 +296,19 @@
}
)
view.dispatch(tr)
// the selection needs to fired after the dispatch - this seems
// to fix an issue with the cursor not moving when the editor is
// first loaded, the first usage of the editor is not ready
// for the anchor to move as well as perform a change
setTimeout(() => {
view.dispatch(
view.state.update({
selection: {
anchor,
},
})
)
}, 1)
return true
}
return false
@ -421,6 +433,7 @@
.code-editor {
font-size: 12px;
height: 100%;
cursor: text;
}
.code-editor :global(.cm-editor) {
height: 100%;