Skip to content

Commit

Permalink
Ensure buffer exists before updating context
Browse files Browse the repository at this point in the history
Ensured that the buffer `ellama--context-buffer` is created if it does not exist
before attempting to update and show context. This prevents errors related to
non-existent buffers. Also, added calls to `ellama-update-context-show` in both
header line and mode line minor modes to ensure context is shown when these
modes are toggled.
  • Loading branch information
s-kostyaev committed Feb 26, 2025
1 parent 5b29e4a commit d78513a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ellama.el
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ the context."
"Update and show context in posframe of header line."
(declare-function posframe-show "ext:posframe")
(declare-function posframe-hide "ext:posframe")
(with-current-buffer ellama--context-buffer
(with-current-buffer (get-buffer-create ellama--context-buffer)
(erase-buffer)
(if ellama--global-context
(insert (format
Expand Down Expand Up @@ -1168,6 +1168,7 @@ the context."
(define-minor-mode ellama-context-header-line-mode
"Toggle Ellama Context header line mode."
:group 'ellama
(ellama-update-context-show)
(add-hook 'window-state-change-hook #'ellama-context-update-header-line)
(if ellama-context-header-line-mode
(ellama-context-update-header-line)
Expand All @@ -1192,6 +1193,7 @@ the context."
(define-minor-mode ellama-context-mode-line-mode
"Toggle Ellama Context mode line mode."
:group 'ellama
(ellama-update-context-show)
(add-hook 'window-state-change-hook #'ellama-context-update-mode-line)
(if ellama-context-mode-line-mode
(ellama-context-update-mode-line)
Expand Down

0 comments on commit d78513a

Please sign in to comment.