File tree 1 file changed +16
-7
lines changed
1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change 142
142
(interactive )
143
143
(if (> (length (window-list )) 2 )
144
144
(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 )))
148
151
(delete-other-windows )
152
+
153
+ ; ; Split the window as needed (either horizontally or vertically)
149
154
(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)))))
154
163
155
164
(defun xah-syntax-color-hex ()
156
165
" Syntax color text of the form 「#ff1100」 and 「#abc」 in current buffer.
You can’t perform that action at this time.
0 commit comments