Skip to content

Commit 05a2ed6

Browse files
authored
Merge pull request #753 from ffeifel/fix/mac-shift-enter-shortcut
fix: add fallback for empty submit and newline shortcuts
2 parents 55133ac + 3af1e32 commit 05a2ed6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/com/devoxx/genie/ui/component/input/CommandAutoCompleteTextField.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ public void keyPressed(@NotNull KeyEvent e) {
108108
newlineShortcutString = stateService.getNewlineShortcutWindows();
109109
}
110110

111+
if (submitShortcutString == null || submitShortcutString.isEmpty()) {
112+
submitShortcutString = "shift ENTER";
113+
}
114+
if (newlineShortcutString == null || newlineShortcutString.isEmpty()) {
115+
newlineShortcutString = SystemInfo.isMac ? "meta ENTER" : "ctrl ENTER";
116+
}
117+
111118
KeyStroke submitKeyStroke = KeyStroke.getKeyStroke(submitShortcutString);
112119
KeyStroke newlineKeyStroke = KeyStroke.getKeyStroke(newlineShortcutString);
113120

src/main/java/com/devoxx/genie/ui/component/input/PromptInputArea.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ public void setFileSelectionCallback(Runnable fileSelectionCallback) {
142142
}
143143

144144
private void setPlaceholderWithKeyboardShortcut(String shortcut) {
145+
if (shortcut == null || shortcut.isEmpty()) {
146+
shortcut = "shift Enter";
147+
}
145148
// Clean up the shortcut text
146149
shortcut = shortcut.replace("pressed", "+")
147150
.replace("meta", "command");
@@ -161,6 +164,10 @@ private void setPlaceholderWithKeyboardShortcut(String shortcut) {
161164
} else {
162165
newlineShortcut = DevoxxGenieStateService.getInstance().getNewlineShortcutMac();
163166
}
167+
168+
if (newlineShortcut == null || newlineShortcut.isEmpty()) {
169+
newlineShortcut = SystemInfo.isMac ? "meta Enter" : "ctrl Enter";
170+
}
164171

165172
// Format the newline shortcut text
166173
newlineShortcut = newlineShortcut.replace("pressed", "+")

0 commit comments

Comments
 (0)