| 
62 | 62 | 		 (const :tag "Right" right))  | 
63 | 63 |   :group 'lsp-ui-imenu)  | 
64 | 64 | 
 
  | 
 | 65 | +(defcustom lsp-ui-imenu-persistent-buffer nil  | 
 | 66 | +  "If non-nil, the `lsp-ui-imenu' buffer will permanently maintain its size.  | 
 | 67 | +ie. it will not be affected by `balance-windows' etc."  | 
 | 68 | +  :type 'boolean  | 
 | 69 | +  :group 'lsp-ui-imenu)  | 
 | 70 | + | 
65 | 71 | (defcustom lsp-ui-imenu-colors '("deep sky blue" "green3")  | 
66 | 72 |   "Color list to cycle through for entry groups."  | 
67 | 73 |   :type '(repeat color)  | 
@@ -314,13 +320,15 @@ ITEMS are used when the kind position is 'left."  | 
314 | 320 |       (set-window-start win 1)  | 
315 | 321 |       (lsp-ui-imenu--move-to-name-beginning)  | 
316 | 322 |       (set-window-dedicated-p win t)  | 
317 |  | -      ;; when `lsp-ui-imenu-window-width' is 0, fit window to buffer  | 
318 |  | -      (if (= lsp-ui-imenu-window-width 0)  | 
319 |  | -          (let ((fit-window-to-buffer-horizontally 'only))  | 
320 |  | -            (fit-window-to-buffer win)  | 
321 |  | -            (window-resize win 3 t))  | 
322 |  | -        (let ((x (- lsp-ui-imenu-window-width (window-width))))  | 
323 |  | -          (window-resize (selected-window) x t))))))  | 
 | 323 | +      (let ((window-size-fixed)) ;; Temporarily set `window-size-fixed' to nil for resizing.  | 
 | 324 | +	;; When `lsp-ui-imenu-window-width' is 0, fit window to buffer:  | 
 | 325 | +	(if (= lsp-ui-imenu-window-width 0)  | 
 | 326 | +            (let ((fit-window-to-buffer-horizontally 'only))  | 
 | 327 | +              (fit-window-to-buffer win)  | 
 | 328 | +              (window-resize win 3 t))  | 
 | 329 | +          (let ((x (- lsp-ui-imenu-window-width (window-width))))  | 
 | 330 | +            (window-resize (selected-window) x t))))  | 
 | 331 | +      )))  | 
324 | 332 | 
 
  | 
325 | 333 | (defun lsp-ui-imenu--kill nil  | 
326 | 334 |   "Kill imenu window."  | 
@@ -377,7 +385,8 @@ ITEMS are used when the kind position is 'left."  | 
377 | 385 |   "Keymap for ‘lsp-ui-peek-mode’.")  | 
378 | 386 | 
 
  | 
379 | 387 | (define-derived-mode lsp-ui-imenu-mode special-mode "lsp-ui-imenu"  | 
380 |  | -  "Mode showing imenu entries.")  | 
 | 388 | +  "Mode showing imenu entries."  | 
 | 389 | +  (setq window-size-fixed (if lsp-ui-imenu-persistent-buffer 'width nil)))  | 
381 | 390 | 
 
  | 
382 | 391 | (defun lsp-ui-imenu--refresh ()  | 
383 | 392 |   "Safe refresh imenu content."  | 
 | 
0 commit comments