Skip to content

Commit 5eef13b

Browse files
committed
Preserve line numbers for blank lines.
This allows differentiating between indenting a blank line and re-indenting the line before it. This situation occurs fairly often: it happens every time the user hits re turn to create a new line, which calls indentation function on the previous line and the newly created line separately. Before this fix, these two calls would incorrectly calculate the same indentation level, e.g. when the previous line just created a block.
1 parent 417dd61 commit 5eef13b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scala-mode-indent.el

+9-2
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,17 @@ tokenization. The parser is not anything like well-formalized, but it can start
746746
at an arbitrary point in the buffer, and except in pathological cases, look at
747747
relatively few lines in order to make a good guess; and it is tolerant to a
748748
certain amount of incorrect or in-progress syntactic forms."
749-
(let* ((initResult (scala-indent:find-analysis-start point))
749+
(let* ((line-no
750+
;; Get the line number while taking blanks into account. This allows
751+
;; differentiating between indenting at a blank line and re-indenting
752+
;; at the line right before it.
753+
(line-number-at-pos
754+
(save-excursion
755+
(when point (goto-char point))
756+
(point))))
757+
(initResult (scala-indent:find-analysis-start point))
750758
(point (car initResult))
751759
(stack (cadr initResult))
752-
(line-no (line-number-at-pos point))
753760
(analysis (scala-indent:analyze-context point stack))
754761
(syntax-elem (list (nth 0 analysis)))
755762
(ctxt-line (nth 1 analysis))

0 commit comments

Comments
 (0)