From 2c3fecf1cc137fba8fed4a80e873ec7733f7476a Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Tue, 8 Oct 2024 18:28:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=B0=83=E8=AF=95=20=E8=B0=83=E8=AF=95=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/codemirror-editor/index.vue | 3 +- .../component/FunctionDebugDrawer.vue | 35 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/ui/src/components/codemirror-editor/index.vue b/ui/src/components/codemirror-editor/index.vue index 0c4203eeeb..5e63c7cad5 100644 --- a/ui/src/components/codemirror-editor/index.vue +++ b/ui/src/components/codemirror-editor/index.vue @@ -21,7 +21,8 @@ defineOptions({ name: 'CodemirrorEditor' }) function getRangeFromLineAndColumn(state: any, line: number, column: number, end_column?: number) { const l = state.doc.line(line) - return { form: l.from + column, to: end_column ? l.from + end_column : l.to } + const form = l.from + column + return { form: form > l.to ? l.to : form, to: end_column ? l.from + end_column : l.to } } const regexpLinter = linter(async (view) => { diff --git a/ui/src/views/function-lib/component/FunctionDebugDrawer.vue b/ui/src/views/function-lib/component/FunctionDebugDrawer.vue index 6ae7793450..e1d00784ee 100644 --- a/ui/src/views/function-lib/component/FunctionDebugDrawer.vue +++ b/ui/src/views/function-lib/component/FunctionDebugDrawer.vue @@ -102,36 +102,21 @@ watch(debugVisible, (bool) => { }) const submit = async (formEl: FormInstance | undefined) => { - if (!formEl) { - functionLibApi - .postFunctionLibDebug(form.value, loading) - .then((res) => { - showResult.value = true - isSuccess.value = true - result.value = res.data - }) - .catch((res) => { + console.log(formEl) + const validate = formEl ? formEl.validate() : Promise.resolve() + validate.then(() => { + functionLibApi.postFunctionLibDebug(form.value, loading).then((res) => { + if (res.code === 500) { showResult.value = true isSuccess.value = false + result.value = res.message + } else { + showResult.value = true + isSuccess.value = true result.value = res.data - }) - } else { - await formEl.validate((valid: any) => { - if (valid) { - functionLibApi.postFunctionLibDebug(form.value, loading).then((res) => { - if (res.code === 500) { - showResult.value = true - isSuccess.value = false - result.value = res.message - } else { - showResult.value = true - isSuccess.value = true - result.value = res.data - } - }) } }) - } + }) } const open = (data: any) => {