Commits

ZyX_I committed 1555cd3

@/fwc: Fixed {optional}+{optional}+{next} completion:
If there were two nested {optional} sections followed by another section
inner {optional} section was ignored (example: `[in l1 [in l2]] + in l3')

Comments (0)

Files changed (3)

plugin/frawor/fwc/topconstructs.vim

         else
             " XXX This implementation does not cover all cases. I won't fix this 
             " because it is too complicated.
-            let failstr=self.getlvarid('fail')
-            call self.let(failstr, 1)
-            let i=0
             if hasnext
+                let failstr=self.getlvarid('fail')
+                call self.let(failstr, 0)
+                let oldcaidxstr=self.getlvarid('oldcaidxstr')
+                let newcaidxstr=self.getlvarid('newcaidxstr')
+                call self.let(oldcaidxstr, a:caidxstr)
+                call self.increment(a:largsstr, -1)
+                let self.failstr=failstr
+                let i=0
                 for opt in a:adescr.optional
-                    call self.if(failstr)
+                    if i>0
+                        call self.if(failstr)
+                    endif
                     call        self.try()
                     call         self.pushms('throwignore')
                     call         self.compadescr(opt, a:idx.'.'.i.'(optional)',
                                     \            'check', 1)
                     call        self.popms()
-                    call            self.let(failstr, 0)
                     call            self.let(a:caidxstr, self.getlastsub())
                     call        self.catch(s:cfreg)
-                    call    self.endif()
+                    call            self.let(failstr, 1)
+                    call        self.up()
+                    if i>0
+                        call    self.endif()
+                    endif
                     let self.subs[-1]=[a:caidxstr]
                     let i+=1
                 endfor
+                unlet self.failstr
+                call self.increment(a:largsstr, 1)
                 call self.if(failstr)
+                call    self.let(newcaidxstr, a:caidxstr)
+                call    self.let(a:caidxstr, oldcaidxstr)
             endif
             let i=0
             for opt in a:adescr.optional
                 let i+=1
             endfor
             if hasnext
+                call    self.let(a:caidxstr, newcaidxstr)
                 call self.endif()
             endif
             return [[a:caidxstr], a:addedsavemsgs]
         call self.let(a:caidxstr, newsub)
     endif
     call self.catch(s:cfreg)
-    if lopt==1 && has_key(a:adescr.optional[0], 'arg')
+    if has_key(self, 'failstr')
+        call self.let(self.failstr, 1)
+    endif
+    if lopt==1 && has_key(a:adescr.optional[0], 'arg') && a:type is# 'pipe'
         let defaults=reverse(map(filter(copy(a:adescr.optional[0].arg),
                     \                   'exists("v:val[0][0]") && '.
                     \                   'v:val[0][0] is# "defval"'),

test/fwccompletetests-os.dat

 
   @$D/
   abc/def/
+
 # vim: cms=#%s fmr=▶,▲ sw=2 ts=2 sts=2 et

test/fwccompletetests.dat

 `[(in list  match /e/)] [(key dict  match /b/]
   @+
   def-ghi abc adb
+
+`[in list [in list2]]
+  @+
+  =s:list
+
+  @abc+
+  =s:list2
 #▶2 {prefixes}
 `{   abc  in list
 +    def  in list2
 
   @abc+
   =s:list2
+`[in list [in list2]] + in list3
+  @+
+  =s:list+s:list3
+
+  @abc+
+  =s:list2+s:list3
 #▶2 {optional}+{prefixes}
 `[in list] {!allfolds}
   @+
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.