emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 51807e12dac: * lisp/tab-bar.el: Fix tab-bar-tab-name-current for


From: Juri Linkov
Subject: master 51807e12dac: * lisp/tab-bar.el: Fix tab-bar-tab-name-current for active minibuffer.
Date: Fri, 7 Jul 2023 03:19:29 -0400 (EDT)

branch: master
commit 51807e12dacbc1abc238ebafb4ba20e27f4bcc81
Author: Juri Linkov <juri@linkov.net>
Commit: Juri Linkov <juri@linkov.net>

    * lisp/tab-bar.el: Fix tab-bar-tab-name-current for active minibuffer.
    
    (tab-bar-tab-name-current): Use get-mru-window in the active minibuffer
    when minibuffer-selected-window is nil after switching to another tab.
    (tab-bar-tab-name-current-with-count)
    (tab-bar-tab-name-truncated): Use tab-bar-tab-name-current.
---
 lisp/tab-bar.el | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/lisp/tab-bar.el b/lisp/tab-bar.el
index f47c4a7bb6c..14b340f6183 100644
--- a/lisp/tab-bar.el
+++ b/lisp/tab-bar.el
@@ -618,13 +618,18 @@ from all windows in the window configuration."
 
 (defun tab-bar-tab-name-current ()
   "Generate tab name from the buffer of the selected window."
-  (buffer-name (window-buffer (minibuffer-selected-window))))
+  ;; `minibuffer-selected-window' loses its original window
+  ;; after switching to another tab while the minibuffer was active,
+  ;; so get the most recently used non-minibuffer window.
+  (buffer-name (window-buffer (or (minibuffer-selected-window)
+                                  (and (window-minibuffer-p)
+                                       (get-mru-window))))))
 
 (defun tab-bar-tab-name-current-with-count ()
   "Generate tab name from the buffer of the selected window.
 Also add the number of windows in the window configuration."
   (let ((count (length (window-list-1 nil 'nomini)))
-        (name (window-buffer (minibuffer-selected-window))))
+        (name (tab-bar-tab-name-current)))
     (if (> count 1)
         (format "%s (%d)" name count)
       (format "%s" name))))
@@ -651,7 +656,7 @@ to `tab-bar-tab-name-truncated'."
   "Generate tab name from the buffer of the selected window.
 Truncate it to the length specified by `tab-bar-tab-name-truncated-max'.
 Append ellipsis `tab-bar-tab-name-ellipsis' in this case."
-  (let ((tab-name (buffer-name (window-buffer (minibuffer-selected-window)))))
+  (let ((tab-name (tab-bar-tab-name-current)))
     (if (< (length tab-name) tab-bar-tab-name-truncated-max)
         tab-name
       (propertize (truncate-string-to-width



reply via email to

[Prev in Thread] Current Thread [Next in Thread]