shithub: mc

Download patch

ref: ba22b4a713f78a66d8e6dd4abad3ce06db3c24c3
parent: 25fa643fa08fd1a2101fd961ce192d96db5ca017
author: Ori Bernstein <[email protected]>
date: Sun Apr 19 17:05:54 EDT 2015

Ignore indent/outdents inside strings.

--- a/support/vim/indent/myr.vim
+++ b/support/vim/indent/myr.vim
@@ -6,10 +6,11 @@
     finish
 endif
 
-function! InComment(lnum, col)
+function! Quoted(lnum, col)
     let stk = synstack(a:lnum, a:col)
     for id in stk
-        if synIDattr(id, "name") == "myrComment"
+        let a = synIDattr(id, "name") 
+        if a == "myrComment" || a == "myrString" || a == "myrChar"
             return 1
         endif
     endfor
@@ -23,7 +24,7 @@
         while idx >= 0
             let idx = match(a:line, p, idx)
             if idx >= 0
-                let ic = InComment(a:lnum, idx)
+                let ic = Quoted(a:lnum, idx)
                 if !ic
                     let matches = matches + 1
                     echo "NOT IN COMMENT " ic " lnum " a:lnum " idx " idx
@@ -69,7 +70,7 @@
                 \    '\<struct\>', '\<union\>',
                 \    '{', '^\s*|', '=\s*$']
         let outpat = ['}', ';;']
-        let outalone = ['\<else\>', '\<elif\>', '}', ';;', '|.*']
+        let outalone = ['\<else\>', '\<elif\>.*', '}', ';;', '|.*']
         let width = &tabstop
 
         let n_in = s:CountMatches(prevln, ln - i, inpat)