Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

fix(hotkeys): preserve hotkeys ending in + during list parsing (#1433)

Henry Sufc0074306195
diff --git a/src/helpers/hotkeyList.js b/src/helpers/hotkeyList.js
index 31c624e21..7fa289c6a 100644
--- a/src/helpers/hotkeyList.js
+++ b/src/helpers/hotkeyList.js
@@ -25,8 +25,9 @@ function parseHotkeyList(value) {
const result = [];
for (let i = 0; i < raw.length; i++) {
let hotkey = raw[i].trim();
- // A non-final segment ending in "+" lost its comma key to the split.
- if (hotkey.endsWith("+") && i < raw.length - 1) {
+ // A non-final segment ending in "+" lost its comma key to the split only if
+ // the next raw element was empty (the trailing comma key produced an empty string).
+ if (hotkey.endsWith("+") && i < raw.length - 1 && raw[i + 1].trim() === "") {
hotkey += HOTKEY_LIST_SEPARATOR;
}
if (!hotkey || seen.has(hotkey)) continue;
diff --git a/src/utils/hotkeys.ts b/src/utils/hotkeys.ts
index 889b44ce8..2730d9ab7 100644
--- a/src/utils/hotkeys.ts
+++ b/src/utils/hotkeys.ts
@@ -24,7 +24,7 @@ export function parseHotkeyList(value?: string | null): string[] {
const result: string[] = [];
for (let i = 0; i < raw.length; i++) {
let hotkey = raw[i].trim();
- if (hotkey.endsWith("+") && i < raw.length - 1) {
+ if (hotkey.endsWith("+") && i < raw.length - 1 && raw[i + 1].trim() === "") {
hotkey += ",";
}
if (!hotkey || seen.has(hotkey)) continue;
diff --git a/test/helpers/hotkeyLabels.test.js b/test/helpers/hotkeyLabels.test.js
index 5e47767bb..704154462 100644
--- a/test/helpers/hotkeyLabels.test.js
+++ b/test/helpers/hotkeyLabels.test.js
@@ -123,3 +123,11 @@ test("isValidHotkeyFormat rejects empty input and combos with empty parts", asyn
assert.equal(isValidHotkeyFormat("Ctrl+"), false);
assert.equal(isValidHotkeyFormat("+K"), false);
});
+
+test("parseHotkeyList preserves hotkeys ending with '+' when followed by another hotkey", async () => {
+ const { parseHotkeyList } = await load();
+
+ assert.deepEqual(parseHotkeyList("Control++,F8"), ["Control++", "F8"]);
+ assert.deepEqual(parseHotkeyList("Control+,,F8"), ["Control+,", "F8"]);
+ assert.deepEqual(parseHotkeyList("Control++,Control+,"), ["Control++", "Control+,"]);
+});
diff --git a/test/helpers/hotkeyList.test.js b/test/helpers/hotkeyList.test.js
index e776cd84f..a58d86d56 100644
--- a/test/helpers/hotkeyList.test.js
+++ b/test/helpers/hotkeyList.test.js
@@ -62,3 +62,10 @@ test("round-trips lists containing comma-key hotkeys", () => {
assert.equal(serialized, "Control+,,F8,GLOBE");
assert.deepEqual(parseHotkeyList(serialized), list);
});
+
+test("preserves hotkeys ending with '+' when followed by another hotkey in a list or array", () => {
+ assert.deepEqual(parseHotkeyList("Control++,F8"), ["Control++", "F8"]);
+ assert.deepEqual(parseHotkeyList(["Control++", "F8"]), ["Control++", "F8"]);
+ assert.deepEqual(parseHotkeyList("Control++,,F8"), ["Control++,", "F8"]);
+ assert.deepEqual(parseHotkeyList("Command++,Control+,,"), ["Command++", "Control+,"]);
+});