Skip to content

Commit

Permalink
fix: check first char instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed May 22, 2024
1 parent 230e3e3 commit 12d6986
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions vs-edit-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@
(when pt (goto-char pt))
(null (re-search-forward "[^ \t]" (line-end-position) t))))

(defun vs-edit--before-char-string ()
"Get the current character as the `string'."
(if (char-before) (string (char-before)) ""))

(defun vs-edit--first-backward-char-in-line-p (ch)
"Check the first character on the left is CH or not, with current line
as boundary."
(save-excursion
(when (re-search-backward "[^[:space:]]" (line-beginning-position) t)
(forward-char 1)
(string= (vs-edit--before-char-string) ch))))

;;
;; (@* "Core" )
;;
Expand All @@ -188,8 +200,7 @@
"Advice for function `newline' (FUNC and ARGS)."
(cond (vs-edit-mode
(let ((vs-edit-mode)
(behind-brackets (save-excursion
(search-backward "{" (line-beginning-position) t))))
(behind-brackets (vs-edit--first-backward-char-in-line-p "{")))
;; 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 Down

0 comments on commit 12d6986

Please sign in to comment.