Cole Miller and Conrad
d88fd00e87
acp: Fix panic with edit file tool ( #36732 )
...
We had a frequent panic when the agent was using our edit file tool. The
root cause was that we were constructing a `BufferDiff` with
`BufferDiff::new`, then calling `set_base_text`, but not waiting for
that asynchronous operation to finish. This means there was a window of
time where the diff's base text was set to the initial value of
`""`--that's not a problem in itself, but it was possible for us to call
`PendingDiff::update` during that window, which calls
`BufferDiff::update_diff`, which calls
`BufferDiffSnapshot::new_with_base_buffer`, which takes two arguments
`base_text` and `base_text_snapshot` that are supposed to represent the
same text. We were getting the first of those arguments from the
`base_text` field of `PendingDiff`, which is set immediately to the
target base text without waiting for `BufferDiff::set_base_text` to run
to completion; and the second from the `BufferDiff` itself, which still
has the empty base text during that window.
As a result of that mismatch, we could end up adding `DeletedHunk` diff
transforms to the multibuffer for the diff card even though the
multibuffer's base text was empty, ultimately leading to a panic very
far away in rendering code.
I've fixed this by adding a new `BufferDiff` constructor for the case
where the buffer contents and the base text are (initially) the same,
like for the diff cards, and so we don't need an async diff calculation.
I also added a debug assertion to catch the basic issue here earlier,
when `BufferDiffSnapshot::new_with_base_buffer` is called with two base
texts that don't match.
Release Notes:
- N/A
---------
Co-authored-by: Conrad <conrad@zed.dev >
2025-08-22 03:48:47 -04:00
..
2025-08-22 03:48:47 -04:00
2025-08-20 14:07:37 +02:00
2025-08-20 14:07:37 +02:00
2025-08-22 01:12:12 -04:00
2025-08-22 05:57:30 +00:00
2025-08-21 17:05:29 -03:00
2025-08-20 12:05:58 +02:00
2025-08-22 05:57:30 +00:00
2025-08-20 14:35:59 +00:00
2025-08-05 18:16:47 +00:00
2025-08-19 21:26:17 +02:00
2025-08-13 13:25:52 -06:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:05:58 +02:00
2025-08-20 12:20:13 +02:00
2025-08-19 20:33:44 +00:00
2025-08-20 14:35:59 +00:00
2025-08-21 15:56:16 +02:00
2025-08-19 14:20:01 +00:00
2025-08-20 12:05:58 +02:00
2025-08-20 12:20:13 +02:00
2025-07-22 11:55:24 -04:00
2025-08-19 21:26:17 +02:00
2025-08-19 13:27:24 +00:00
2025-08-22 03:48:47 -04:00
2025-08-19 21:26:17 +02:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-21 19:59:42 -04:00
2025-05-04 08:28:39 +00:00
2025-08-21 17:19:57 +00:00
2025-08-07 01:28:41 +00:00
2025-08-11 15:34:34 +02:00
2025-08-21 13:59:18 +00:00
2025-08-21 18:50:06 +00:00
2025-04-02 13:26:34 -07:00
2025-08-20 12:20:13 +02:00
2025-04-02 13:26:34 -07:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-20 14:07:37 +02:00
2025-08-21 19:59:42 -04:00
2025-08-19 21:26:17 +02:00
2025-08-20 12:05:58 +02:00
2025-08-19 20:33:44 +00:00
2025-08-19 20:26:56 -06:00
2025-07-06 14:52:16 +02:00
2025-08-20 12:20:13 +02:00
2025-08-21 19:08:26 +02:00
2025-06-25 09:42:30 +02:00
2025-08-20 14:35:59 +00:00
2025-08-20 23:41:06 +00:00
2025-08-20 14:07:37 +02:00
2025-08-20 12:20:13 +02:00
2025-08-21 20:19:17 +05:30
2025-08-20 20:14:30 +02:00
2025-07-10 21:08:43 +02:00
2025-08-19 20:33:44 +00:00
2025-08-20 12:05:58 +02:00
2025-08-16 19:00:31 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-20 02:11:17 +00:00
2025-08-21 19:59:42 -04:00
2025-08-20 15:17:28 +02:00
2025-08-19 21:26:17 +02:00
2025-08-20 12:20:13 +02:00
2025-08-19 13:27:24 +00:00
2025-08-06 10:53:20 +02:00
2025-08-20 20:14:30 +02:00
2025-08-19 13:27:24 +00:00
2025-08-22 01:12:12 -04:00
2025-08-20 14:07:37 +02:00
2025-08-19 21:26:17 +02:00
2025-08-21 19:59:42 -04:00
2025-08-20 18:45:40 +00:00
2025-08-21 17:19:57 +00:00
2025-08-19 13:27:24 +00:00
2025-08-20 12:20:13 +02:00
2025-04-02 13:26:34 -07:00
2025-08-20 01:47:28 -03:00
2025-06-03 13:18:29 +02:00
2025-08-20 03:40:39 +00:00
2025-08-18 21:54:35 +00:00
2025-08-19 20:33:44 +00:00
2025-06-18 16:01:28 +05:30
2025-08-20 12:20:13 +02:00
2025-08-21 17:52:17 +02:00
2025-08-18 21:54:35 +00:00
2025-08-22 01:12:12 -04:00
2025-08-22 01:12:12 -04:00
2025-08-19 13:27:24 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-05-20 23:06:07 +00:00
2025-08-21 15:56:16 +02:00
2025-07-25 09:36:43 -04:00
2025-08-21 09:24:34 +03:00
2025-08-21 20:51:36 -03:00
2025-08-20 12:20:13 +02:00
2025-05-20 23:06:07 +00:00
2025-07-02 21:14:33 -04:00
2025-08-20 12:20:13 +02:00
2025-08-09 15:25:47 -04:00
2025-08-20 19:30:11 +00:00
2025-07-17 14:25:55 +00:00
2025-07-08 14:34:57 +00:00
2025-08-19 20:33:44 +00:00
2025-08-19 13:27:24 +00:00
2025-08-06 10:44:15 -04:00
2025-08-20 14:07:37 +02:00
2025-08-19 21:26:17 +02:00
2025-08-19 21:26:17 +02:00
2025-06-27 14:31:31 -06:00
2025-08-21 09:24:34 -04:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:05:58 +02:00
2025-08-20 12:20:13 +02:00
2025-08-19 21:26:17 +02:00
2025-08-21 19:08:26 +02:00
2025-08-20 15:17:28 +02:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-21 09:24:34 +03:00
2025-08-20 12:20:13 +02:00
2025-08-19 13:27:24 +00:00
2025-05-23 14:53:53 +00:00
2025-08-21 19:08:26 +02:00
2025-08-21 09:37:45 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:05:58 +02:00
2025-08-19 13:27:24 +00:00
2025-08-20 12:20:13 +02:00
2025-08-21 06:48:04 +00:00
2025-08-20 12:20:13 +02:00
2025-04-02 13:26:34 -07:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-05-20 23:06:07 +00:00
2025-08-19 13:27:24 +00:00
2025-08-21 15:56:16 +02:00
2025-08-20 12:20:13 +02:00
2025-08-22 00:18:25 +00:00
2025-08-19 21:26:17 +02:00
2025-08-19 21:26:17 +02:00
2025-08-19 13:27:24 +00:00
2025-08-19 13:27:24 +00:00
2025-04-02 13:26:34 -07:00
2025-08-20 12:20:13 +02:00
2025-08-19 20:33:44 +00:00
2025-08-18 21:54:35 +00:00
2025-08-19 21:26:17 +02:00
2025-08-20 12:20:13 +02:00
2025-08-19 21:26:17 +02:00
2025-08-19 20:33:44 +00:00
2025-08-21 19:59:42 -04:00
2025-08-22 00:21:36 +02:00
2025-08-21 19:08:26 +02:00
2025-08-20 14:35:59 +00:00
2025-08-19 21:26:17 +02:00
2025-08-15 15:37:52 -04:00
2025-08-20 12:20:13 +02:00
2025-08-22 10:17:37 +05:30
2025-08-19 21:26:17 +02:00
2025-08-20 12:20:13 +02:00
2025-04-02 13:26:34 -07:00
2025-08-20 12:20:13 +02:00
2025-08-08 15:34:36 -03:00
2025-05-06 10:18:48 +00:00
2025-08-20 14:07:37 +02:00
2025-08-21 09:37:45 +00:00
2025-08-22 10:17:37 +05:30
2025-08-20 12:20:13 +02:00
2025-05-23 19:31:25 +00:00
2025-07-30 23:03:53 +05:30
2025-08-21 19:08:26 +02:00
2025-06-13 06:32:29 +00:00
2025-08-15 13:54:24 +03:00
2025-08-21 21:20:22 -06:00
2025-06-18 21:26:12 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-19 20:33:44 +00:00
2025-08-22 05:54:25 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:05:58 +02:00
2025-08-21 19:59:42 -04:00
2025-08-14 13:39:33 +00:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-08-20 12:20:13 +02:00
2025-04-23 20:54:09 +00:00