Skip to content

Commit

Permalink
fix: Don't newline on when not opening
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed May 22, 2024
1 parent 10fd369 commit 230e3e3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions vs-edit-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@
(defun vs-edit-newline (func &rest args)
"Advice for function `newline' (FUNC and ARGS)."
(cond (vs-edit-mode
(let (vs-edit-mode)
(let ((vs-edit-mode)
(behind-brackets (save-excursion
(search-backward "{" (line-beginning-position) t))))
;; XXX: Make sure indent on the empty line.
(when (vs-edit--current-line-totally-empty-p) (indent-for-tab-command))
;; XXX: Maintain same indentation for the previous line.
Expand All @@ -197,7 +199,8 @@
(forward-line -1)
(when (vs-edit--current-line-totally-empty-p) (insert ln-cur))))
;; XXX: Make sure brackets on newline!
(when (or (string= "}" (string-trim (thing-at-point 'line)))
(when (or (and behind-brackets
(string= "}" (string-trim (thing-at-point 'line))))
(and (derived-mode-p 'sgml-mode)
(vs-edit--tag-on-line-p)))
(save-excursion (newline-and-indent)))))
Expand Down

0 comments on commit 230e3e3

Please sign in to comment.