agent_ui: Auto-capture file context on paste (#42982)

Closes #42972


https://github.com/user-attachments/assets/98f2d3dc-5682-4670-b636-fa8ea2495c69

Release Notes:

- Added automatic file context detection when pasting code into the AI
agent panel. Pasted code now displays as collapsible badges showing the
file path and line numbers (e.g., "app/layout.tsx (18-25)").

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
This commit is contained in:
ozzy
2025-12-08 17:32:04 +01:00
committed by GitHub
co-authored by Bennet Bo Fenner
parent 18421845eb
commit f6a6630171
4 changed files with 268 additions and 18 deletions
+8 -6
View File
@@ -11,7 +11,6 @@ use editor::{ClipboardSelection, Editor, SelectionEffects};
use gpui::Context;
use gpui::Window;
use language::Point;
use multi_buffer::MultiBufferRow;
use settings::Settings;
struct HighlightOnYank;
@@ -198,11 +197,14 @@ impl Vim {
if kind.linewise() {
text.push('\n');
}
clipboard_selections.push(ClipboardSelection {
len: text.len() - initial_len,
is_entire_line: false,
first_line_indent: buffer.indent_size_for_line(MultiBufferRow(start.row)).len,
});
clipboard_selections.push(ClipboardSelection::for_buffer(
text.len() - initial_len,
false,
start..end,
&buffer,
editor.project(),
cx,
));
}
}