ZIm/crates
Max Brunsfeld c3075dfe9a
Fix bugs in diff hunk highlighting (#18454)
Fixes https://github.com/zed-industries/zed/issues/18405

In https://github.com/zed-industries/zed/pull/18313, we introduced a
problem where git addition highlights might spuriously return when
undoing certain changes. It turned out, there were already some cases
where git hunk highlighting was incorrect when editing at the boundaries
of expanded diff hunks.

In this PR, I've introduced a test helper method for more rigorously
(and readably) testing the editor's git state. You can assert about the
entire state of an editor's diff decorations using a formatted diff:

```rust
    cx.assert_diff_hunks(
        r#"
        - use some::mod1;
          use some::mod2;
          const A: u32 = 42;
        - const B: u32 = 42;
          const C: u32 = 42;
          fn main() {
        -     println!("hello");
        +     //println!("hello");
              println!("world");
        +     //
        +     //
          }
          fn another() {
              println!("another");
        +     println!("another");
          }
        - fn another2() {
              println!("another2");
          }
        "#
        .unindent(),
    );
```

This will assert about the editor's actual row highlights, not just the
editor's internal hunk-tracking state.

I rewrote all of our editor diff tests to use these more high-level
assertions, and it caught the new bug, as well as some pre-existing bugs
in the highlighting of added content.

The problem was how we *remove* highlighted rows. Previously, it relied
on supplying exactly the same range as one that we had previously
highlighted. I've added a `remove_highlighted_rows(ranges)` APIs which
is much simpler - it clears out any row ranges that intersect the given
ranges (which is all that we need for the Git diff use case).

Release Notes:

- N/A
2024-09-27 11:14:28 -07:00
..
activity_indicator lsp: Remove reinstall, update config (#18318) 2024-09-25 10:45:56 -07:00
anthropic Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
assets add ui::Vector and separate images from icons (#17815) 2024-09-13 17:44:16 -04:00
assistant Fix bugs in diff hunk highlighting (#18454) 2024-09-27 11:14:28 -07:00
assistant_slash_command Introduce a new /delta command (#17903) 2024-09-17 08:47:08 -06:00
assistant_tool assistant: Add basic tool invocation (#17368) 2024-09-04 14:32:20 -04:00
audio Update Rust crate rodio to 0.19.0 (#17389) 2024-09-16 21:55:32 -06:00
auto_update Bump release_notes to v2 endpoint (#18108) 2024-09-19 19:43:32 -04:00
breadcrumbs Add missing shortcuts in tooltips (#18282) 2024-09-27 11:06:48 +02:00
call Fix renames over language server for SSH remoting (#17897) 2024-09-16 16:20:17 -06:00
channel Add the ability to propose changes to a set of buffers (#18170) 2024-09-20 18:28:50 -04:00
cli zed: Use CLI env for lang servers, tasks, terminal (#17075) 2024-08-29 18:09:06 +02:00
client client: Remove unused fs dependency (#18324) 2024-09-25 10:02:35 +02:00
clock Add the ability to propose changes to a set of buffers (#18170) 2024-09-20 18:28:50 -04:00
collab Remove Qwen2 model (#18444) 2024-09-27 13:30:25 -04:00
collab_ui Fix renames over language server for SSH remoting (#17897) 2024-09-16 16:20:17 -06:00
collections gpui: Add SVG rendering to img element and generic asset cache (#9931) 2024-03-29 17:09:49 -07:00
command_palette chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
command_palette_hooks chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
context_servers context_servers: Remove context_type from ResourceContent (#18097) 2024-09-19 15:51:48 -04:00
copilot Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
db Add system_id (#18040) 2024-09-19 07:20:27 -04:00
dev_server_projects chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
diagnostics Remove replica_id from MultiBuffers (#18141) 2024-09-20 10:48:27 -04:00
docs_preprocessor Don't rely on relative path for docs preprocessor (#16883) 2024-08-26 11:43:13 -04:00
editor Fix bugs in diff hunk highlighting (#18454) 2024-09-27 11:14:28 -07:00
evals Allow using system node (#18172) 2024-09-23 15:28:04 -06:00
extension Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
extension_api zed_extension_api: Use v0.2.0 WIT types (#17802) 2024-09-13 14:49:50 -04:00
extension_cli remote_server: Remove dependency on libssl and libcrypto (#15446) 2024-09-18 23:29:34 +02:00
extensions_ui Revert "settings: Remove auxiliary Content types where possible (#16744)" (#17768) 2024-09-12 14:46:08 -04:00
feature_flags /auto (#16696) 2024-09-13 13:17:49 -04:00
feedback Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
file_finder Avoid unwrap in file finder (#18374) 2024-09-26 10:31:17 +03:00
file_icons chore: Clean up allocs around project panel (#15422) 2024-07-29 14:21:41 +02:00
fs /auto (#16696) 2024-09-13 13:17:49 -04:00
fsevent Retain run loop (#11241) 2024-04-30 23:31:59 -06:00
fuzzy Improve slash commands (#16195) 2024-08-13 23:06:07 -07:00
git git: Do not rescan .git on fsmonitor events (#18326) 2024-09-25 11:34:27 +02:00
git_hosting_providers Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
go_to_line Fix bugs in diff hunk highlighting (#18454) 2024-09-27 11:14:28 -07:00
google_ai Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
gpui Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
gpui_macros add ui::Vector and separate images from icons (#17815) 2024-09-13 17:44:16 -04:00
headless Allow using system node (#18172) 2024-09-23 15:28:04 -06:00
html_to_markdown chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
http_client Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
image_viewer chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
indexed_docs chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
inline_completion_button chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
install_cli Fix flickering (#9012) 2024-03-11 10:45:57 +01:00
isahc_http_client Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
journal chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
language Remove non-wrapping settings from the language configuration (#18412) 2024-09-26 23:43:58 +03:00
language_model Remove Qwen2 model (#18444) 2024-09-27 13:30:25 -04:00
language_selector use ssh lsp store (#17655) 2024-09-10 15:51:01 -04:00
language_tools ssh remoting: Fix cmd-o (#18308) 2024-09-24 16:23:08 -06:00
languages Move adapters to remote (#18359) 2024-09-25 15:29:04 -07:00
live_kit_client chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
live_kit_server live_kit_server: Re-remove protocol submodule (#15317) 2024-07-26 21:10:56 -04:00
lsp lsp: Remove reinstall, update config (#18318) 2024-09-25 10:45:56 -07:00
markdown Allow using system node (#18172) 2024-09-23 15:28:04 -06:00
markdown_preview Upgrade tree sitter and all grammars (#17734) 2024-09-16 17:10:57 -07:00
media Update Rust crate bindgen to 0.70.0 (#17024) 2024-08-28 22:12:49 -07:00
menu open picker (#14524) 2024-07-15 17:04:15 -06:00
multi_buffer project search: Fix search results not being highlighted (#18273) 2024-09-24 15:03:22 +02:00
node_runtime Make python run local worktree LSPs (#18353) 2024-09-25 12:45:41 -07:00
notifications Replace Default trait bound with a zero function on Summary/Dimension (#17975) 2024-09-17 19:43:59 -06:00
ollama Fix read timeout for ollama (#18417) 2024-09-27 00:36:17 -06:00
open_ai Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
outline Fix bugs in diff hunk highlighting (#18454) 2024-09-27 11:14:28 -07:00
outline_panel ssh remoting: Fix cmd-o (#18308) 2024-09-24 16:23:08 -06:00
paths macos: Use ~/Library/Caches/Zed instead of ~/.cache/zed (#17949) 2024-09-17 13:51:11 -04:00
picker Update typos-cli to v1.24.6. Add scripts/check-spelling. Fix typos (#17961) 2024-09-17 15:08:14 -04:00
prettier Allow using system node (#18172) 2024-09-23 15:28:04 -06:00
project project: Fix worktree store event missing in remote projects (#18376) 2024-09-27 08:55:35 +02:00
project_panel ssh remoting: Fix cmd-o (#18308) 2024-09-24 16:23:08 -06:00
project_symbols Fix renames over language server for SSH remoting (#17897) 2024-09-16 16:20:17 -06:00
proto Remove old project search code path, bump min-supported zed version for collaboration (#18404) 2024-09-26 12:10:39 -07:00
quick_action_bar Add missing shortcuts in tooltips (#18282) 2024-09-27 11:06:48 +02:00
recent_projects ssh remoting: Show error if opening connection timed out (#18401) 2024-09-27 09:31:45 +02:00
refineable Move Clippy configuration to the workspace level (#8891) 2024-03-05 12:01:17 -05:00
release_channel chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
remote ssh remoting: Show error if opening connection timed out (#18401) 2024-09-27 09:31:45 +02:00
remote_server SSH Remoting: Fix bugs in worktree syncing (#18406) 2024-09-26 12:03:57 -07:00
repl Styling option for separating terminal view background from background color (#17611) 2024-09-17 12:51:31 -04:00
rich_text Disable definition lists in Markdown (#17648) 2024-09-10 11:16:27 -04:00
rope Replace Default trait bound with a zero function on Summary/Dimension (#17975) 2024-09-17 19:43:59 -06:00
rpc Remove Qwen2 model (#18444) 2024-09-27 13:30:25 -04:00
search Add missing shortcuts in tooltips (#18282) 2024-09-27 11:06:48 +02:00
semantic_index Add a slash command for automatically retrieving relevant context (#17972) 2024-09-20 18:09:18 -04:00
semantic_version Extract SemanticVersion into its own crate (#9956) 2024-03-29 12:11:57 -04:00
session chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
settings settings: Show notification when user/project settings fail to parse (#18122) 2024-09-20 10:53:06 +02:00
settings_ui chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
snippet Correct escaping in snippets (#14912) 2024-07-22 00:57:34 +02:00
snippet_provider Fix file descriptors leak in evals (#18351) 2024-09-25 15:21:00 -04:00
sqlez Workspace persistence for SSH projects (#17996) 2024-09-19 17:51:28 +02:00
sqlez_macros Replace lazy_static with std::sync::LazyLock (#16066) 2024-08-20 14:27:33 -04:00
story chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
storybook Fix missing tooltips for selected buttons (#18435) 2024-09-27 14:16:14 +02:00
sum_tree chore: Fix violations of elided_named_lifetimes (#18330) 2024-09-25 12:27:57 +02:00
supermaven Implement grapheme support for supermaven completions (#18279) 2024-09-24 08:49:07 -06:00
supermaven_api chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
tab_switcher tab_switcher: Add file and project search icons (#17115) 2024-09-17 14:48:05 +02:00
task chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
tasks_ui ssh remoting: Fix cmd-o (#18308) 2024-09-24 16:23:08 -06:00
telemetry_events Add system_id (#18040) 2024-09-19 07:20:27 -04:00
terminal Fix sending alt-enter in terminal (#18363) 2024-09-25 18:01:33 -04:00
terminal_view Add missing shortcuts in tooltips (#18282) 2024-09-27 11:06:48 +02:00
text Add the ability to propose changes to a set of buffers (#18170) 2024-09-20 18:28:50 -04:00
theme Add ability to separately set background color for highlighted brackets (#17566) 2024-09-26 12:48:23 -04:00
theme_importer chore: Another round of style lints fixes (#17519) 2024-09-07 02:36:55 +02:00
theme_selector settings_ui: Add theme settings controls (#15115) 2024-07-24 16:25:52 -04:00
time_format chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
title_bar Fix missing tooltips for selected buttons (#18435) 2024-09-27 14:16:14 +02:00
ui Fix missing tooltips for selected buttons (#18435) 2024-09-27 14:16:14 +02:00
ui_input Rename ui_text_field crate to ui_input (#13949) 2024-07-08 17:05:30 -04:00
ui_macros Add ui_macros crate & DerivePathStr derive macro (#17811) 2024-09-13 16:45:16 -04:00
util Fix opening file with colon (#17281) 2024-09-17 11:19:07 -04:00
vcs_menu chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
vim vim: Command selection fixes (#18424) 2024-09-27 10:06:19 -06:00
welcome Welcome tweaks (#17874) 2024-09-16 08:29:46 -04:00
workspace ssh remoting: Show error message if project path does not exist (#18343) 2024-09-25 18:08:34 +02:00
worktree SSH Remoting: Fix bugs in worktree syncing (#18406) 2024-09-26 12:03:57 -07:00
zed Stop leaking isahc assumption (#18408) 2024-09-26 14:01:05 -06:00
zed_actions Improve Linux terminal keymap and context menu (#16845) 2024-08-26 01:01:46 +03:00