ZyX_I avatar 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

test/fwccomplete.ok

 ::: 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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.