Skip to content

Commit ffdc76f

Browse files
authored
Merge pull request #44 from tninja/kang_feat_2
Fix: Improve context handling for exception investiation function
2 parents a9facd6 + 4126ffb commit ffdc76f

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

ai-code-discussion.el

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,19 @@ Argument ARG is the prefix argument."
169169
(context-section
170170
(if full-buffer-context
171171
(concat "\n\nContext:\n" full-buffer-context)
172-
(concat
173-
(when clipboard-content
174-
(concat "\n\nClipboard context (error/exception):\n" clipboard-content))
175-
(when compilation-content
176-
(concat "\n\nCompilation output:\n" compilation-content))
177-
(when (and region-text (not compilation-content) (not clipboard-content))
178-
(concat "\n\nSelected code:\n" region-text)))))
172+
(let ((context-blocks nil))
173+
(when clipboard-content
174+
(push (concat "Clipboard context (error/exception):\n" clipboard-content)
175+
context-blocks))
176+
(when compilation-content
177+
(push (concat "Compilation output:\n" compilation-content)
178+
context-blocks))
179+
(when region-text
180+
(push (concat "Selected code:\n" region-text)
181+
context-blocks))
182+
(when context-blocks
183+
(concat "\n\nContext:\n"
184+
(mapconcat #'identity (nreverse context-blocks) "\n\n"))))))
179185
(default-question "How to fix the error in this code? Please analyze the error, explain the root cause, and provide the corrected code to resolve the issue: ")
180186
(prompt-label
181187
(cond

0 commit comments

Comments
 (0)