Fix #4577: WS not at BOL is deleted to tab columns

Changes the behavior of
doom/backward-delete-whitespace-to-column
to only delete to the closest tab column if there
is only whitespace between point and BOL.
This coincides with what the comments state to be
the original intent.
This commit is contained in:
Jan Felix Langenbach 2021-05-13 01:06:30 +02:00
parent 6d2c6b44fa
commit 6aa29e82ae

View file

@ -71,7 +71,7 @@ possible, or just one char if that's not possible."
(ignore-errors (sp-get-thing)))) (ignore-errors (sp-get-thing))))
(op (plist-get context :op)) (op (plist-get context :op))
(cl (plist-get context :cl)) (cl (plist-get context :cl))
open-len close-len) open-len close-len current-column)
(cond ;; When in strings (sp acts weird with quotes; this is the fix) (cond ;; When in strings (sp acts weird with quotes; this is the fix)
;; Also, skip closing delimiters ;; Also, skip closing delimiters
((and op cl ((and op cl
@ -89,13 +89,12 @@ possible, or just one char if that's not possible."
(> tab-width 1) (> tab-width 1)
(not (bolp)) (not (bolp))
(not (doom-point-in-string-p)) (not (doom-point-in-string-p))
(save-excursion (>= (- (skip-chars-backward " \t")) tab-width))) (save-excursion (>= (- (skip-chars-backward " \t"))
(let ((movement (% (current-column) tab-width))) (setq current-column (current-column)))))
(let ((movement (% current-column tab-width)))
(when (= movement 0) (when (= movement 0)
(setq movement tab-width)) (setq movement tab-width))
(delete-char (- movement))) (delete-char (- movement))))
(unless (memq (char-before) (list ?\n ?\ ))
(insert " ")))
;; Otherwise do a regular delete ;; Otherwise do a regular delete
((delete-char -1))))) ((delete-char -1)))))