Skip to content

Commit 65c48e3

Browse files
committed
Fix indentation behavior after last line in buffer fixes #145
1 parent 4a6d256 commit 65c48e3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

elixir-smie.el

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@
169169

170170
(defun elixir-smie--semi-ends-match ()
171171
"Return non-nil if the current line concludes a match block."
172+
(when (not (eobp))
172173
(save-excursion
173174
;; Warning: Recursion.
174175
;; This is easy though.
@@ -195,7 +196,7 @@
195196
;; And if we're NOT on a blank line, move to the end of the line, and see
196197
;; if we're looking back at a block operator.
197198
(t (move-end-of-line 1)
198-
(looking-back elixir-smie--block-operator-regexp))))))
199+
(looking-back elixir-smie--block-operator-regexp)))))))
199200

200201
(defun elixir-smie--same-line-as-parent (parent-pos child-pos)
201202
"Return non-nil if `child-pos' is on same line as `parent-pos'."
@@ -211,7 +212,10 @@
211212
((and (or (looking-at elixir-smie--comment-regexp)
212213
(looking-at "[\n#]"))
213214
(elixir-smie--implicit-semi-p))
214-
(if (eolp) (forward-char 1) (forward-comment 1))
215+
(when (not (save-excursion
216+
(forward-comment 1)
217+
(eobp)))
218+
(if (eolp) (forward-char 1) (forward-comment 1)))
215219
;; Note: `elixir-smie--semi-ends-match' will be called when the point is at
216220
;; the beginning of a new line. Keep that in mind.
217221
(if (elixir-smie--semi-ends-match)
@@ -313,7 +317,6 @@
313317
(cond
314318
((smie-rule-parent-p "if")
315319
(smie-rule-parent))
316-
317320
((and (smie-rule-parent-p "(")
318321
(save-excursion
319322
(goto-char (cadr smie--parent))

0 commit comments

Comments
 (0)