Skip to content

Commit 53c4675

Browse files
committed
purescript-indentation.el: don't modify buffer if indentation unchanged
Currently calling indentation on a line that is already indented as expected results in buffer being modified despite no changes being actually done. Avoid this by checking if current indentation already matches the one we just calculated and only reindenting on mismatch.
1 parent eacc61a commit 53c4675

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

purescript-indentation.el

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -196,17 +196,18 @@ autofill-mode."
196196
(end-of-line))))
197197

198198
(defun purescript-indentation-reindent (col)
199-
(beginning-of-line)
200-
(delete-region (point)
201-
(progn
202-
(when (and (eq purescript-literate 'bird)
203-
(eq (char-after) ?>))
204-
(forward-char))
205-
(skip-syntax-forward "-")
206-
(point)))
207-
(when (eq purescript-literate 'bird)
208-
(insert ">"))
209-
(indent-to col))
199+
(unless (= col (purescript-indentation-current-indentation))
200+
(beginning-of-line)
201+
(delete-region (point)
202+
(progn
203+
(when (and (eq purescript-literate 'bird)
204+
(eq (char-after) ?>))
205+
(forward-char))
206+
(skip-syntax-forward "-")
207+
(point)))
208+
(when (eq purescript-literate 'bird)
209+
(insert ">"))
210+
(indent-to col)))
210211

211212
(defun purescript-indentation-current-indentation ()
212213
(if (eq purescript-literate 'bird)

0 commit comments

Comments
 (0)