Skip to content

Commit 82833a0

Browse files
committed
fix issue once there are temp window
1 parent b3d03bf commit 82833a0

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

lisp/init-display.el

+16-7
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,24 @@
142142
(interactive)
143143
(if (> (length (window-list)) 2)
144144
(error "Can't toggle with more than 2 windows!")
145-
(let ((func (if (window-full-height-p)
146-
#'split-window-vertically
147-
#'split-window-horizontally)))
145+
146+
(let* ((current-buffer (window-buffer))
147+
(other-window-buffer (window-buffer (next-window)))
148+
(func (if (window-full-height-p)
149+
#'split-window-vertically
150+
#'split-window-horizontally)))
148151
(delete-other-windows)
152+
153+
;; Split the window as needed (either horizontally or vertically)
149154
(funcall func)
150-
(save-selected-window
151-
(other-window 1)
152-
(switch-to-buffer (other-buffer)))))
153-
)
155+
156+
;; Ensure that the original buffer from the other window is switched to
157+
(let ((other-win (selected-window)))
158+
(select-window (next-window other-win))
159+
(switch-to-buffer other-window-buffer)
160+
161+
;; Return to the original window to maintain focus if needed
162+
(select-window other-win)))))
154163

155164
(defun xah-syntax-color-hex ()
156165
"Syntax color text of the form 「#ff1100」 and 「#abc」 in current buffer.

0 commit comments

Comments
 (0)