Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guides/editor_features/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ editing their contents.
- `Shift+↓`/`Shift+↑` - multi-select cells
- `Enter` - edit selected cell
- `a`/`b` - new cell above/below
- `q` - new SQL cell below
- `c`/`v` - copy/paste cells
- `s` - save notebook
- `Shift+Enter` - run cell and move to next
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/components/editor/navigation/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useMemo } from "react";
import { mergeProps, useFocusWithin, useKeyboard } from "react-aria";
import { DATA_FOR_CELL_ID } from "@/components/data-table/cell-utils";
import { aiCompletionCellAtom } from "@/core/ai/state";
import { maybeAddMarimoImport } from "@/core/cells/add-missing-import";
import { cellIdsAtom, notebookAtom, useCellActions } from "@/core/cells/cells";
import { useCellFocusActions } from "@/core/cells/focus";
import type { CellId } from "@/core/cells/ids";
Expand All @@ -26,6 +27,7 @@ import {
closeSignatureHint,
signatureHintField,
} from "@/core/codemirror/completion/signature-hint";
import { LanguageAdapters } from "@/core/codemirror/language/LanguageAdapters";
import {
hotkeysAtom,
isAiFeatureEnabled,
Expand Down Expand Up @@ -551,6 +553,23 @@ export function useCellNavigationProps(
actions.createNewCell({ cellId, before: false, autoFocus: true });
return true;
},
"command.createSqlCellAfter": (cellId) => {
if (Events.hasModifier(evt)) {
return false;
}
const importCellId = maybeAddMarimoImport({
autoInstantiate: true,
createNewCell: actions.createNewCell,
fromCellId: cellId,
});
Comment on lines +560 to +564

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you likely want to add a marimo Import before the cell. Right now it's
selected cell -> import cell -> new sql cell.

There is a before keywords for maybeAddMarimoImport

And you should add tests for this feature too

actions.createNewCell({
cellId: importCellId ?? cellId,
before: false,
autoFocus: true,
code: LanguageAdapters.sql.defaultCode,
});
return true;
},
"cell.delete": () => {
// Only handle if destructive_delete is enabled
if (!userConfig.keymap.destructive_delete) {
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/core/hotkeys/hotkeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,11 @@ const DEFAULT_HOT_KEY = {
group: "Command",
key: "b",
},
"command.createSqlCellAfter": {
name: "Create a SQL cell after current cell",
group: "Command",
key: "q",
},
"command.copyCell": {
name: "Copy cell",
group: "Command",
Expand Down
Loading