File tree Expand file tree Collapse file tree 4 files changed +18
-21
lines changed Expand file tree Collapse file tree 4 files changed +18
-21
lines changed Original file line number Diff line number Diff line change @@ -13,21 +13,13 @@ interface EditorScrollCommandsSettings {
13
13
}
14
14
15
15
const DEFAULT_SETTINGS : EditorScrollCommandsSettings = {
16
- offset : 2 ,
17
- interval : 5 ,
16
+ offset : 4 ,
17
+ interval : 6 ,
18
18
accelerate : true ,
19
- accelRate : 0.024 ,
20
- maxAccel : 4 ,
19
+ accelRate : 0.02 ,
20
+ maxAccel : 8 ,
21
21
}
22
22
23
- const MODIFIER_TO_EVENT_PROP = {
24
- 'Alt' : 'altKey' ,
25
- 'Shift' : 'shiftKey' ,
26
- 'Ctrl' : 'ctrlKey' ,
27
- 'Meta' : 'metaKey' ,
28
- 'Mod' : Platform . isMacOS ? 'metaKey' : 'ctrlKey' ,
29
- } ;
30
-
31
23
export default class EditorScrollCommandsPlugin extends Plugin {
32
24
settings : EditorScrollCommandsSettings ;
33
25
intervalId : number ;
@@ -76,14 +68,18 @@ export default class EditorScrollCommandsPlugin extends Plugin {
76
68
( hotkey . key == event . code ) ||
77
69
( 'Key' + hotkey . key == event . code ) ;
78
70
79
- let allModsMatched = hotkey . modifiers . every ( m => {
80
- let modifierPressed = MODIFIER_TO_EVENT_PROP [ m ] ;
71
+ if ( ! keyMatched ) { return false ; }
81
72
82
- // @ts -expect-error
83
- return event [ modifierPressed ] ;
84
- } ) ;
73
+ let mods = hotkey . modifiers ;
74
+ let modKeyState = Platform . isMacOS ? event . metaKey : event . ctrlKey ;
75
+
76
+ if ( event . altKey != mods . contains ( 'Alt' ) ) { return false ; }
77
+ if ( event . ctrlKey != mods . contains ( 'Ctrl' ) ) { return false ; }
78
+ 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 ; }
85
81
86
- return keyMatched && allModsMatched ;
82
+ return true ;
87
83
} ) ;
88
84
}
89
85
Original file line number Diff line number Diff line change 1
1
{
2
2
"id" : " editor-scroll-commands" ,
3
3
"name" : " Editor Scroll Commands" ,
4
- "version" : " 1.1.1 " ,
4
+ "version" : " 1.1.2 " ,
5
5
"minAppVersion" : " 0.15.0" ,
6
6
"description" : " Add scroll commands for editor, so you can assign hotkeys." ,
7
7
"author" :
" Andrey Sorokin <[email protected] >" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " editor-scroll-commands" ,
3
- "version" : " 1.1.1 " ,
3
+ "version" : " 1.1.2 " ,
4
4
"description" : " Add scroll commands for editor, so you can assign hotkeys." ,
5
5
"main" : " main.js" ,
6
6
"scripts" : {
Original file line number Diff line number Diff line change 2
2
"1.0.0" : " 0.15.0" ,
3
3
"1.0.3" : " 0.15.0" ,
4
4
"1.1.0" : " 0.15.0" ,
5
- "1.1.1" : " 0.15.0"
5
+ "1.1.1" : " 0.15.0" ,
6
+ "1.1.2" : " 0.15.0"
6
7
}
You can’t perform that action at this time.
0 commit comments