File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change 11import * as monaco from 'monaco-editor'
2- import EmacsExtension from 'monaco-emacs'
3- import { initVimMode } from './vim'
42
53export function updateKeybindings ( bindings : monaco . extra . IUserFriendlyKeybinding [ ] ) : void {
64 const keybindingService = monaco . extra . StandaloneServices . get ( monaco . extra . IKeybindingService ) as monaco . extra . StandaloneKeybindingService
75 keybindingService . setUserKeybindings ( bindings )
86}
97
8+ class PromiseDisposable implements monaco . IDisposable {
9+ constructor ( private promise : Promise < monaco . IDisposable > ) { }
10+
11+ dispose ( ) : void {
12+ this . promise . then ( disposable => disposable . dispose ( ) , console . error )
13+ }
14+ }
15+
1016export function updateEditorKeybindingsMode (
1117 editor : monaco . editor . IStandaloneCodeEditor ,
1218 keyBindingsMode : 'classic' | 'vim' | 'emacs' = 'classic' ,
1319 statusBarElement : Element
1420) : monaco . IDisposable {
1521 switch ( keyBindingsMode ) {
1622 case 'vim' : {
17- return initVimMode ( editor , statusBarElement )
23+ return new PromiseDisposable ( import ( './vim' ) . then ( ( { initVimMode } ) => {
24+ return initVimMode ( editor , statusBarElement )
25+ } ) )
1826 }
1927 case 'emacs' : {
20- const emacsExtension = new EmacsExtension ( editor )
21- emacsExtension . start ( )
22- return emacsExtension
28+ return new PromiseDisposable ( import ( 'monaco-emacs' ) . then ( ( { default : EmacsExtension } ) => {
29+ const emacsExtension = new EmacsExtension ( editor )
30+ emacsExtension . start ( )
31+ return emacsExtension
32+ } ) )
2333 }
2434 default : {
2535 return {
You can’t perform that action at this time.
0 commit comments