branch: elpa/evil
commit 9bbebe05d490b0c54cffb07e4bc60ee6f3833773
Author: Ankit Pandey <anpan...@protonmail.com>
Commit: Tom Dalziel <33435574+tomd...@users.noreply.github.com>

    evil-window-delete: Attempt to close tab if tab bar is enabled
---
 evil-commands.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/evil-commands.el b/evil-commands.el
index d44d3ab7e7..82a9817169 100644
--- a/evil-commands.el
+++ b/evil-commands.el
@@ -4398,11 +4398,17 @@ This is equivalent to Vim's alternate buffer."
       (switch-to-buffer (car previous-place)))))
 
 (evil-define-command evil-window-delete ()
-  "Delete the current window.
+  "Delete the current window or tab.
 If `evil-auto-balance-windows' is non-nil then all children of
 the deleted window's parent window are rebalanced."
   (let ((p (window-parent)))
-    (delete-window)
+    ;; If tabs are enabled and this is the only visible window, then attempt to
+    ;; close this tab.
+    (if (and (boundp 'tab-bar-mode)
+             tab-bar-mode
+             (not p))
+        (tab-close)
+      (delete-window))
     (when evil-auto-balance-windows
       ;; balance-windows raises an error if the parent does not have
       ;; any further children (then rebalancing is not necessary anyway)

Reply via email to