]> git.notmuchmail.org Git - notmuch/blobdiff - vim/plugin/notmuch.vim
vim: don't toggle folds that are inside closed folds in show mode
[notmuch] / vim / plugin / notmuch.vim
index 9932e3f16095e65931280701cda284b7b21ea233..cb7f34f5e2e14985ecea8403e9c574f40d9245ce 100644 (file)
@@ -639,9 +639,19 @@ function! s:NM_show_fold_toggle(key, type, fold)
                 let act = 'close'
         endif
         for fld in info['folds']
-                if fld[0] == a:type
-                        exec printf('%dfold%s', fld[1], act)
+                if fld[0] != a:type
+                        continue
+                endif
+                "let idx = fld[3]
+                "let msg = info['msgs'][idx]
+                "if has_key(msg,'match') && msg['match'] == '0'
+                "        continue
+                "endif
+                let cls = foldclosed(fld[1])
+                if cls != -1 && cls != fld[1]
+                        continue
                 endif
+                exec printf('%dfold%s', fld[1], act)
         endfor
         exec printf('nnoremap <buffer> %s :call <SID>NM_show_fold_toggle(''%s'', ''%s'', %d)<CR>', a:key, a:key, a:type, !a:fold)
 endfunction