Skip to content

Commit

Permalink
add selection
Browse files Browse the repository at this point in the history
  • Loading branch information
aiwenmo committed Dec 20, 2023
1 parent 4c77961 commit 2ee315b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion dinky-web/src/pages/DataStudio/HeaderContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => {
editor.focus();
editorInstance.current = editor;
tabsItem.monacoInstance = monaco;
tabsItem.editorInstance = editor;

editor.onDidChangeCursorPosition((e) => {
props.footContainer.codePosition = [e.position.lineNumber, e.position.column];
Expand Down Expand Up @@ -143,7 +144,7 @@ const StudioEditor: React.FC<EditorProps & connect> = (props) => {
/>
<CodeEdit
monacoRef={tabsItem?.monacoInstance}
editorRef={editorInstance}
editorRef={tabsItem?.editorInstance}
code={tabsItem?.params?.taskData?.statement}
language={matchLanguage(tabsItem?.subType)}
editorDidMount={editorDidMount}
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/pages/DataStudio/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ export interface TabsItemType {
closable: boolean;
path: string[];
monacoInstance: React.RefObject<Monaco | undefined>;
editorInstance: editor.IStandaloneCodeEditor | undefined;
console: ConsoleType;
isModified: boolean;
}
Expand Down

0 comments on commit 2ee315b

Please sign in to comment.