File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
packages/editor-codemirror/src/behaviors Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 13
13
*
14
14
*/
15
15
16
- import { indentWithTab } from "@codemirror/commands" ;
16
+ import { indentLess , indentMore } from "@codemirror/commands" ;
17
17
18
18
import { indentOnInput } from "@codemirror/language" ;
19
19
import { keymap } from "@codemirror/view" ;
20
20
21
21
import { Behavior } from "." ;
22
+ import { acceptCompletion , completionStatus } from "@codemirror/autocomplete" ;
22
23
23
- export function indentBehavior ( ) : Behavior {
24
+ export function tabBehavior ( ) : Behavior {
24
25
return {
25
26
extensions : [
26
27
indentOnInput ( ) ,
27
- keymap . of ( [ indentWithTab ] )
28
+ keymap . of ( [
29
+ {
30
+ key : 'Tab' ,
31
+ preventDefault : true ,
32
+ shift : indentLess ,
33
+ run : e => {
34
+ if ( ! completionStatus ( e . state ) ) return indentMore ( e ) ;
35
+ return acceptCompletion ( e ) ;
36
+ } ,
37
+ } ,
38
+ ] )
28
39
]
29
- }
40
+ } ;
30
41
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ import { CodeViewOptions, ExtensionContext } from "editor";
27
27
import { langModeBehavior } from './langmode' ;
28
28
import { keyboardBehavior } from './keyboard' ;
29
29
import { findBehavior } from './find' ;
30
- import { indentBehavior } from './indent' ;
30
+ import { tabBehavior } from './indent' ;
31
31
import { trackSelectionBehavior } from './trackselection' ;
32
32
import { themeBehavior } from './theme' ;
33
33
import { prefsBehavior } from './prefs' ;
@@ -63,7 +63,7 @@ export function createBehaviors(context: BehaviorContext): Behavior[] {
63
63
langModeBehavior ( context ) ,
64
64
completionBehavior ( context ) ,
65
65
findBehavior ( context ) ,
66
- indentBehavior ( ) ,
66
+ tabBehavior ( ) ,
67
67
themeBehavior ( context ) ,
68
68
prefsBehavior ( context ) ,
69
69
trackSelectionBehavior ( context ) ,
You can’t perform that action at this time.
0 commit comments