From 2ee315b1543aa4672b3f0fb98345c99877549149 Mon Sep 17 00:00:00 2001 From: wenmo <32723967+wenmo@users.noreply.github.com> Date: Thu, 21 Dec 2023 00:06:56 +0800 Subject: [PATCH] add selection --- .../src/pages/DataStudio/HeaderContainer/index.tsx | 10 +++++++++- .../DataStudio/MiddleContainer/StudioEditor/index.tsx | 3 ++- dinky-web/src/pages/DataStudio/model.ts | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx index 44005a4fed..b4a0dfd906 100644 --- a/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx +++ b/dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx @@ -189,9 +189,17 @@ const HeaderContainer = (props: connect) => { const handlerDebug = async () => { if (!currentData) return; + let selectsql = null; + if (currentTab.editorInstance) { + selectsql = currentTab.editorInstance.getModel().getValueInRange(currentTab.editorInstance.getSelection()); + } + if (selectsql == null || selectsql == '') { + selectsql = currentData.statement; + } + const res = await debugTask( l('pages.datastudio.editor.debugging', '', { jobName: currentData.name }), - currentData + {...currentData, statement: selectsql} ); if (!res) return; diff --git a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx index 76a24c0c9a..cc6ea7c7ed 100644 --- a/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx +++ b/dinky-web/src/pages/DataStudio/MiddleContainer/StudioEditor/index.tsx @@ -106,6 +106,7 @@ const StudioEditor: React.FC = (props) => { editor.focus(); editorInstance.current = editor; tabsItem.monacoInstance = monaco; + tabsItem.editorInstance = editor; editor.onDidChangeCursorPosition((e) => { props.footContainer.codePosition = [e.position.lineNumber, e.position.column]; @@ -143,7 +144,7 @@ const StudioEditor: React.FC = (props) => { /> ; + editorInstance: editor.IStandaloneCodeEditor | undefined; console: ConsoleType; isModified: boolean; }