Skip to content

Commit 08fb6f3

Browse files
committed
fix: correct mod, meta and ctrl match
1 parent ccb107b commit 08fb6f3

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

main.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,21 @@ export default class EditorScrollCommandsPlugin extends Plugin {
6464

6565
isScrollHotkeyEvent(event: KeyboardEvent, hotkeys: Hotkey[]) {
6666
return hotkeys?.some((hotkey: Hotkey) => {
67-
let keyMatched =
68-
(hotkey.key == event.code) ||
69-
('Key' + hotkey.key == event.code);
70-
71-
if (!keyMatched) { return false; }
67+
if ((hotkey.key != event.code) &&
68+
('Key' + hotkey.key != event.code)) { return false; }
7269

7370
let mods = hotkey.modifiers;
74-
let modKeyState = Platform.isMacOS ? event.metaKey : event.ctrlKey;
7571

7672
if (event.altKey != mods.contains('Alt')) { return false; }
77-
if (event.ctrlKey != mods.contains('Ctrl')) { return false; }
7873
if (event.shiftKey != mods.contains('Shift')) { return false; }
79-
if (event.metaKey != mods.contains('Meta')) { return false; }
80-
if (modKeyState != mods.contains('Mod')) { return false; }
74+
75+
if (Platform.isMacOS) {
76+
if (event.metaKey != (mods.contains('Mod') || mods.contains('Meta')))
77+
{ return false; }
78+
} else {
79+
if (event.ctrlKey != (mods.contains('Mod') || mods.contains('Ctrl')))
80+
{ return false; }
81+
}
8182

8283
return true;
8384
});

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "editor-scroll-commands",
33
"name": "Editor Scroll Commands",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"minAppVersion": "0.15.0",
66
"description": "Add scroll commands for editor, so you can assign hotkeys.",
77
"author": "Andrey Sorokin <[email protected]>",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "editor-scroll-commands",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
44
"description": "Add scroll commands for editor, so you can assign hotkeys.",
55
"main": "main.js",
66
"scripts": {

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"1.0.3": "0.15.0",
44
"1.1.0": "0.15.0",
55
"1.1.1": "0.15.0",
6-
"1.1.2": "0.15.0"
6+
"1.1.2": "0.15.0",
7+
"1.1.3": "0.15.0"
78
}

0 commit comments

Comments
 (0)