From 6aa29e82ae26d7de97e6b8dad7ab36a7401311b0 Mon Sep 17 00:00:00 2001 From: Jan Felix Langenbach Date: Thu, 13 May 2021 01:06:30 +0200 Subject: [PATCH] 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. --- modules/config/default/autoload/text.el | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/config/default/autoload/text.el b/modules/config/default/autoload/text.el index 9d0144aaa..8fad8de66 100644 --- a/modules/config/default/autoload/text.el +++ b/modules/config/default/autoload/text.el @@ -71,7 +71,7 @@ possible, or just one char if that's not possible." (ignore-errors (sp-get-thing)))) (op (plist-get context :op)) (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) ;; Also, skip closing delimiters ((and op cl @@ -89,13 +89,12 @@ possible, or just one char if that's not possible." (> tab-width 1) (not (bolp)) (not (doom-point-in-string-p)) - (save-excursion (>= (- (skip-chars-backward " \t")) tab-width))) - (let ((movement (% (current-column) tab-width))) + (save-excursion (>= (- (skip-chars-backward " \t")) + (setq current-column (current-column))))) + (let ((movement (% current-column tab-width))) (when (= movement 0) (setq movement tab-width)) - (delete-char (- movement))) - (unless (memq (char-before) (list ?\n ?\ )) - (insert " "))) + (delete-char (- movement)))) ;; Otherwise do a regular delete ((delete-char -1)))))