 
     (when (and isQuotation
                (not endQuotationAtNextLine)
-               (not nextLineMoreIndented))
+               (<= nextLineIndentDiff 0))
       (insert "end}")
       (indent-according-to-mode)
       (previous-line)

    (save-excursion
      (let ((thisLineIndent (zomp-current-line-indent)))
        (next-line)
        (setq nextLineMoreIndented (< thisLineIndent (zomp-current-line-indent)))))

    (save-excursion
      (back-to-indentation)

        (wordAtLineBeginning "")
        (endAtNextLine nil)
        (endQuotationAtNextLine nil)
        (nextLineIndentDiff 0))

    (setq isAtEnd (looking-at " *$"))

