@@ -151,27 +151,18 @@ function! s:LibmodalEnterWithCombos(modeName, modeCombos) abort
151151
152152 " Stop timers that would clear user input.
153153 if exists (' s:' . a: modeName . ' ModeTimer' )
154-
154+ if timer_info (s: {a: modeName }ModeTimer) != []
155+ echom ' Stopping timer.'
156+ endif
155157 call timer_stop (s: {a: modeName }ModeTimer)
156158 unlet s: {a: modeName }ModeTimer
157- endif
158-
159- " Initialize variables necessary to execute combo modes.
160- if ! exists (' s:' . a: modeName . ' ModeCombos' )
161- " Build a pseudo-parse-tree.
162- let s: {a: modeName }ModeCombos = {}
163- for l: splitCombos in s: SplitArgDict (a: modeCombos )
164- let s: {a: modeName }ModeCombos = s: NewComboDict (
165- \ s: {a: modeName }ModeCombos, l: splitCombos , a: modeCombos [join (l: splitCombos , ' ' )]
166- \)
167- endfor
168-
169- " Initialize the input history variable.
170- call s: ClearLocalInput (a: modeName )
159+ else
160+ echom " IT DOESN'T EXIST???????? >>>>>> s:" . a: modeName . " ModeTimer"
171161 endif
172162
173163 " Append latest input to history.
174164 let s: {a: modeName }ModeInput .= g: {a: modeName }ModeInput
165+ echom ' CURRENT INPUT IS ' . s: {a: modeName }ModeInput
175166
176167 " Try to grab the command for the input.
177168 let l: command = s: Get (s: {a: modeName }ModeCombos, s: {a: modeName }ModeInput)
@@ -188,23 +179,27 @@ function! s:LibmodalEnterWithCombos(modeName, modeCombos) abort
188179 " If timers are on.
189180 if s: True (s: {a: modeName }ModeTimeout)
190181
191- let l: clearFunc = function (' s:ClearLocalInput' , [a: modeName ])
182+ let l: ClearFunc = function (' s:ClearLocalInput' , [a: modeName ])
192183
193184 " There is a command for this entry.
194185 if has_key (l: command , s: EX_KEY )
186+ " Get the command that was embedded into the ' ' key.
187+ let l: command = l: command [s: EX_KEY ]
195188
196189 " Start a timer to execute user input and then clear the input history.
197- let s {a: modeName }ModeTimer = timer_start (
190+ echom ' Starting s:' . a: modeName . ' ModeTimer to execute command: ' . string (l: command )
191+ let s: {a: modeName }ModeTimer = timer_start (
198192 \ &timeoutlen , {
199- \ _ - > execute (l: command . ' | call ' . l: clearFunc )
193+ \ _ - > execute ([ l: command, ' call ' . l: ClearFunc ] )
200194 \ }
201195 \)
202196
203197 else
204198
205199 " Start a timer to clear the user's input.
206- let s {a: modeName }ModeTimer = timer_start (
207- \ &timeoutlen , {_ - > l: clearFunc }
200+ echom ' Starting s:' . a: modeName . ' ModeTimer to clear input.'
201+ let s: {a: modeName }ModeTimer = timer_start (
202+ \ &timeoutlen , {_ - > execute ([' echom "Timer ran out. clearning."' , ' call ' . l: ClearFunc ])}
208203 \)
209204 endif
210205 endif
@@ -396,9 +391,7 @@ function! libmodal#complete(...) abort
396391
397392 let l: completions = []
398393 for l: completion in s: completions
399- echom ' TESTING >>' l: completion
400394 if stridx (l: completion , l: word ) > -1
401- echom ' << ACCEPTED'
402395 let l: completions = add (l: completions , l: completion )
403396 endif
404397 endfor
@@ -415,30 +408,34 @@ endfunction
415408" * `a:3` => `supressExit`
416409function ! libmodal#Enter (... ) abort
417410 " Define mode indicator
411+ unlockvar l: indicator
418412 let l: indicator = s: NewIndicator (a: 1 )
419413 lockvar l: indicator
420414
421415 " Initialize the window state for the mode.
416+ unlockvar l: winState
422417 let l: winState = s: Init ()
423418 lockvar l: winState
424419
425420 " Convert the modename to lowercase.
421+ unlockvar l: lower
426422 let l: lower = tolower (a: 1 )
427423 lockvar l: lower
428424
429425 " Name of variable used for input.
426+ unlockvar l: input
430427 let l: input = l: lower . " ModeInput"
431428 lockvar l: input
432429
433430 " If the third argument, representing exit supression, has been passed.
431+ unlockvar l: exit
434432 if len (a: 000 ) > 2 && s: True (a: 3 )
435433 " Create the variable used to control the exit.
436434 let l: exit = l: lower . " ModeExit"
437435 let g: {l: exit } = 0
438436 else
439437 let l: exit = 0
440438 endif
441-
442439 lockvar l: exit
443440
444441 if type (a: 2 ) == v: t_dict
@@ -449,9 +446,26 @@ function! libmodal#Enter(...) abort
449446 let l: timeout = g: libmodalTimeouts
450447 endif
451448
449+ unlockvar s: {l: lower }ModeTimeout
452450 let s: {l: lower }ModeTimeout = l: timeout
453451 lockvar s: {l: lower }ModeTimeout
454452
453+ echom ' l:timeout >>> ' . string (s: {l: lower }ModeTimeout)
454+ echom ' s:' . l: lower . ' ModeTimeout >>> ' . string (s: {l: lower }ModeTimeout)
455+
456+ " Build a pseudo-parse-tree.
457+ let s: {l: lower }ModeCombos = {}
458+ for l: splitCombos in s: SplitArgDict (a: 2 )
459+ let s: {l: lower }ModeCombos = s: NewComboDict (
460+ \ s: {l: lower }ModeCombos, l: splitCombos , a: 2 [join (l: splitCombos , ' ' )]
461+ \)
462+ endfor
463+
464+ echom ' COMBOS >>> ' . string (s: {l: lower }ModeCombos)
465+
466+ " Initialize the input history variable.
467+ call s: ClearLocalInput (l: lower )
468+
455469 endif
456470
457471 " Outer loop to keep accepting commands
@@ -473,9 +487,12 @@ function! libmodal#Enter(...) abort
473487 break
474488 endif
475489
476- if type (a: 2 ) == v: t_func | call a: 2 ()
477- elseif type (a: 2 ) == v: t_dict | call s: LibmodalEnterWithCombos (l: lower , a: 2 )
478- else | break
490+ if type (a: 2 ) == v: t_func
491+ call a: 2 ()
492+ elseif type (a: 2 ) == v: t_dict
493+ call s: LibmodalEnterWithCombos (l: lower , a: 2 )
494+ else
495+ break
479496 endif
480497
481498 catch
@@ -500,20 +517,22 @@ endfunction
500517" * `a:2` => `modeCallback` OR `modeCommands`
501518function ! libmodal#Prompt (... ) abort
502519 " Define mode indicator
520+ unlockvar l: indicator
503521 let l: indicator = ' * ' . a: 1 . ' > '
504522 lockvar l: indicator
505523
506524 " Name of variable used for input.
525+ unlockvar l: input
507526 let l: input = tolower (a: 1 ) . " ModeInput"
508527 lockvar l: input
509528
529+ unlockvar l: completions
510530 if type (a: 2 ) == v: t_dict
511531 let l: completions = keys (a: 2 )
512- lockvar l: completions
513532 elseif len (a: 000 ) > 2
514533 let l: completions = a: 3
515- lockvar l: completions
516534 endif
535+ lockvar l: completions
517536
518537 " Outer loop to keep accepting commands
519538 while 1 | try
0 commit comments