From dbe27b13dc5cde2866bb2c630275b74327b1c1ef Mon Sep 17 00:00:00 2001
From: Robert Buonpastore <robert.buonpastore@gmail.com>
Date: Sat, 4 Feb 2017 11:44:20 -0500
Subject: [PATCH] Fix tcl indentation

Match indentation of the line with the closing brace to the indentation
of the line with the corresponding opening brace.

For instance consider the following incorrectly formatted block:
if true {
  if true {
    }
      }

With the current tcl indent file, it reindents (==) into the following
still incorrectly formatted block:
if true {
  if true {
}
}

This patch will reindent either one of the above incorrectly formatted
blocks into the following correctly formatted block:
if true {
  if true {
  }
}
---
 runtime/indent/tcl.vim | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/runtime/indent/tcl.vim b/runtime/indent/tcl.vim
index a92f57d67..a0183ddfb 100644
--- a/runtime/indent/tcl.vim
+++ b/runtime/indent/tcl.vim
@@ -1,7 +1,7 @@
 " Vim indent file
 " Language:	    Tcl
 " Maintainer:	    Nikolai Weibull <now@bitwi.se>
-" Latest Revision:  2006-12-20
+" Latest Revision:  2016-02-04
 
 if exists("b:did_indent")
   finish
@@ -56,7 +56,8 @@ function GetTclIndent()
   if line =~ '^\s*\*'
     return cindent(v:lnum)
   elseif line =~ '^\s*}'
-    return indent(v:lnum) - &sw
+    let [lnum, _] = searchpairpos('{', '', '}', "bnW")
+    return indent(lnum)
   endif
 
   let pnum = s:prevnonblanknoncomment(v:lnum - 1)
-- 
2.11.0

