From 9d02d3a7ee7d4fa3203823d73e09d5ab2b11c679 Mon Sep 17 00:00:00 2001
From: mtaran-google <mtaran@google.com>
Date: Wed, 4 Jun 2014 14:34:50 -0700
Subject: [PATCH] [python mode] Return to parent indentation level when scope
 is closed.

This makes it work correctly when the hanging indent is different from the indent unit.
---
 mode/python/python.js | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mode/python/python.js b/mode/python/python.js
index 3a86c278..45dd63ba 100644
--- a/mode/python/python.js
+++ b/mode/python/python.js
@@ -320,8 +320,10 @@
         var closing = textAfter && textAfter.charAt(0) == scope.type;
         if (scope.align != null)
           return scope.align - (closing ? 1 : 0);
+        else if (closing && state.scopes.length > 1)
+          return state.scopes[state.scopes.length - 2].offset;
         else
-          return scope.offset - (closing ? conf.indentUnit : 0);
+          return scope.offset;
       },
 
       lineComment: "#",
-- 
GitLab