nit editors reactivity on change

This commit is contained in:
Ruben Fiszel
2025-05-31 05:15:24 +02:00
parent ed61d97700
commit db873be43b
3 changed files with 12 additions and 18 deletions
+4 -6
View File
@@ -367,13 +367,13 @@
}
}
function updateCode(): boolean {
function updateCode() {
const ncode = getCode()
if (code == ncode) {
return false
return
}
code = ncode
return true
dispatch('change', ncode)
}
export function append(code: string): void {
@@ -1287,9 +1287,7 @@
editor?.onDidChangeModelContent((event) => {
timeoutModel && clearTimeout(timeoutModel)
timeoutModel = setTimeout(() => {
if (updateCode()) {
dispatch('change', code)
}
updateCode()
}, changeTimeout)
ataModel && clearTimeout(ataModel)
@@ -163,13 +163,13 @@
editor?.setValue(ncode)
}
function updateCode(): boolean {
function updateCode() {
const ncode = getCode()
if (code == ncode) {
return false
return
}
code = ncode
return true
dispatch('change', ncode)
}
function updatePlaceholderVisibility(value: string) {
@@ -379,9 +379,7 @@
suggestion = ''
timeoutModel && clearTimeout(timeoutModel)
timeoutModel = setTimeout(() => {
if (updateCode()) {
dispatch('change', { code })
}
updateCode()
}, 200)
})
@@ -472,22 +472,20 @@
editor.addCommand(KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.Digit7, function () {})
})
function updateCode(): boolean {
function updateCode() {
const ncode = getCode()
if (code == ncode) {
return false
return
}
code = ncode
return true
dispatch('change', code)
}
let timeoutModel: NodeJS.Timeout | undefined = undefined
editor.onDidChangeModelContent((event) => {
timeoutModel && clearTimeout(timeoutModel)
timeoutModel = setTimeout(() => {
if (updateCode()) {
dispatch('change', { code })
}
updateCode()
}, 200)
})