You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ju...@apache.org on 2023/07/11 20:19:59 UTC
[superset] branch master updated: feat(sqllab): add shortcut for run current sql (#24329)
This is an automated email from the ASF dual-hosted git repository.
justinpark pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 1473d97055 feat(sqllab): add shortcut for run current sql (#24329)
1473d97055 is described below
commit 1473d9705569d45a3fd6b962e5530d45d43cecc5
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Tue Jul 11 13:19:52 2023 -0700
feat(sqllab): add shortcut for run current sql (#24329)
Co-authored-by: Justin Park <ju...@apache.org>
---
.../src/SqlLab/components/SqlEditor/index.jsx | 60 ++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
index dc018e0b7f..093b90e686 100644
--- a/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
+++ b/superset-frontend/src/SqlLab/components/SqlEditor/index.jsx
@@ -332,6 +332,66 @@ const SqlEditor = ({
}
},
},
+ {
+ name: 'runQuery3',
+ key: 'ctrl+shift+enter',
+ descr: t('Run current query'),
+ func: editor => {
+ if (!editor.getValue().trim()) {
+ return;
+ }
+ const session = editor.getSession();
+ const cursorPosition = editor.getCursorPosition();
+ const totalLine = session.getLength();
+ let end = editor.find(';', {
+ backwards: false,
+ skipCurrent: true,
+ start: cursorPosition,
+ })?.end;
+ if (!end || end.row < cursorPosition.row) {
+ end = {
+ row: totalLine + 1,
+ column: 0,
+ };
+ }
+ let start = editor.find(';', {
+ backwards: true,
+ skipCurrent: true,
+ start: cursorPosition,
+ })?.end;
+ let currentLine = editor.find(';', {
+ backwards: true,
+ skipCurrent: true,
+ start: cursorPosition,
+ })?.end?.row;
+ if (
+ !currentLine ||
+ currentLine > cursorPosition.row ||
+ (currentLine === cursorPosition.row &&
+ start?.column > cursorPosition.column)
+ ) {
+ currentLine = 0;
+ }
+ let content =
+ currentLine === start?.row
+ ? session.getLine(currentLine).slice(start.column).trim()
+ : session.getLine(currentLine).trim();
+ while (!content && currentLine < totalLine) {
+ currentLine += 1;
+ content = session.getLine(currentLine).trim();
+ }
+ if (currentLine !== start?.row) {
+ start = { row: currentLine, column: 0 };
+ }
+ editor.selection.setRange({
+ start: start ?? { row: 0, column: 0 },
+ end,
+ });
+ startQuery();
+ editor.selection.clearSelection();
+ editor.moveCursorToPosition(cursorPosition);
+ },
+ },
{
name: 'newTab',
key: userOS === 'Windows' ? 'ctrl+q' : 'ctrl+t',