Commits

ZyX_I committed b2fda46

@/fwc: Added completion of {next} section

Comments (0)

Files changed (3)

plugin/frawor/fwc/topconstructs.vim

             \             nextsub, addedsavemsgs)
     let addedsavemsgs=a:addedsavemsgs
     let hasnext=s:F.hasnext(a:adescr, 'next')
-    if hasnext
-        if !addedsavemsgs
-            call self.addsavemsgs()
-            let addedsavemsgs=1
+    if self.type is 'complete'
+        call self.addif(a:largsstr.'>='.self.getlastsub())
+                    \.compilearg(a:adescr.next[0], a:idx.'.(next)')
+                \.up()
+        if hasnext
+            call self.pushms('throwignore')
+                        \.try()
+                            \.while(a:caidxstr.'<'.a:largsstr.'-1')
+                                \.compilearg(a:adescr.next[0], a:idx.'.(next)',
+                                \            'check')
+                                \.increment(a:caidxstr)
+                            \.up()
+                        \.catch(s:cfreg)
+                            \.call('remove(@$@variants, 0, -1)')
+                        \.up()
         endif
-        call self.try().pushms('throw')
-    endif
-    call self.while(a:caidxstr.'<'.a:largsstr)
-                \.compilearg(a:adescr.next[0], a:idx.'.(next)')
-                \.increment(a:caidxstr)
-                \.up()
-    if hasnext
-        call self.addrestmsgs(1).catch(s:cfreg).popms().up()
+    else
+        if hasnext
+            if !addedsavemsgs
+                call self.addsavemsgs()
+                let addedsavemsgs=1
+            endif
+            call self.try().pushms('throw')
+        endif
+        call self.while(a:caidxstr.'<'.a:largsstr)
+                    \.compilearg(a:adescr.next[0], a:idx.'.(next)')
+                    \.increment(a:caidxstr)
+                    \.up()
+        if hasnext
+            call self.addrestmsgs(1).catch(s:cfreg).popms().up()
+        endif
     endif
     return [[a:caidxstr], addedsavemsgs]
 endfunction
 ::: Section <Built-in completion functions/if>
 ::: Section <Different sections/{required}>
 ::: Section <Different sections/{optional}>
+::: Section <Different sections/{next}>
 ::: Section <Different sections/{actions}>
+::: Section <Different sections/{next}+{actions}>
 <<< messages

test/fwccompletetests.dat

 
   @- -+
   =sort(keys(s:dict))
+#▶2 {next}
+`+ in list
+  @+
+  =s:list
+
+  @b+
+  =s:list
 #▶2 {actions}
 `<abc in list
 + dbf in list2
 
   @x+
   =s:list
+#▶2 {next}+{actions}
+`+ in list
++<abc in list2
++ def ->
+  @+
+  =s:list+['abc', 'def']
+
+  @a+
+  =s:list2
+
+  @abc d+
+  =[]
 # vim: cms=#%s fmr=▶,▲ sw=2 ts=2 sts=2 et