Skip to content

Commit

Permalink
purescript-indentation.el: don't modify buffer if indentation unchanged
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Hi-Angel committed Sep 12, 2024
1 parent eacc61a commit 53c4675
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions purescript-indentation.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,18 @@ autofill-mode."
(end-of-line))))

(defun purescript-indentation-reindent (col)
(beginning-of-line)
(delete-region (point)
(progn
(when (and (eq purescript-literate 'bird)
(eq (char-after) ?>))
(forward-char))
(skip-syntax-forward "-")
(point)))
(when (eq purescript-literate 'bird)
(insert ">"))
(indent-to col))
(unless (= col (purescript-indentation-current-indentation))
(beginning-of-line)
(delete-region (point)
(progn
(when (and (eq purescript-literate 'bird)
(eq (char-after) ?>))
(forward-char))
(skip-syntax-forward "-")
(point)))
(when (eq purescript-literate 'bird)
(insert ">"))
(indent-to col)))

(defun purescript-indentation-current-indentation ()
(if (eq purescript-literate 'bird)
Expand Down

0 comments on commit 53c4675

Please sign in to comment.