Skip to content

Commit 5986ab8

Browse files
committed
gptel-transient: Use `transient--window' for width calculations
* gptel-transient.el: (gptel-system-prompt--format, gptel--setup-directive-menu, gptel-tools): When discovering the width of the transient window, use `transient--window' as an argument. Otherwise, `window-width' will return the width of the active window where the transient was launched from, and if the frame has been split horizontally, things get truncated incorrectly. If `transient-display-buffer-action' has been set to open windows on the left or right hand side, it also works since transient always fits the window to the buffer.
1 parent d57eb98 commit 5986ab8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

gptel-transient.el

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Handle formatting for system messages when the active
196196
(propertize "]" 'face 'transient-heading))
197197
(if message
198198
(gptel--describe-directive
199-
message (max (- (window-width) 12) 14) "")
199+
message (max (- (window-width transient--window) 12) 14) "")
200200
"[No system message set]")))
201201

202202
(defun gptel--tools-init-value (obj)
@@ -579,7 +579,7 @@ If EXTERNAL is non-nil, include external sources of directives."
579579
(cl-loop for (type . prompt) in gptel-directives
580580
;; Avoid clashes with the custom directive key
581581
with unused-keys = (delete ?s (number-sequence ?a ?z))
582-
with width = (window-width)
582+
with width = (window-width transient--window)
583583
for name = (symbol-name type)
584584
for key = (seq-find (lambda (k) (member k unused-keys)) name (seq-first unused-keys))
585585
do (setq unused-keys (delete key unused-keys))
@@ -701,7 +701,7 @@ only (\"oneshot\")."
701701
(concat (make-string (max (- 20 (length name)) 0) ? )
702702
(propertize
703703
(concat "(" (gptel--describe-directive
704-
(gptel-tool-description tool) (- (window-width) 40))
704+
(gptel-tool-description tool) (- (window-width transient--window) 40))
705705
")")
706706
'face 'shadow))
707707
(gptel-tool-name tool)

0 commit comments

Comments
 (0)