Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
10def9d
Map the new interface
SomeoneToIgnore Jul 17, 2025
26a538a
Draft the new data structures
SomeoneToIgnore Jul 18, 2025
94c56d0
Start to connect the API in the editor
SomeoneToIgnore Jul 21, 2025
47a20cf
Reorder the hint data
SomeoneToIgnore Jul 23, 2025
3756214
Map the editor-frontend API
SomeoneToIgnore Aug 26, 2025
9a359b9
Map backend interfaces down to LSP fetching
SomeoneToIgnore Sep 2, 2025
04f606e
Refactor new inlay hints cache interactions
SomeoneToIgnore Sep 8, 2025
5ba3d9e
Propagate inlay_hints_2 usage to the editor
SomeoneToIgnore Sep 8, 2025
d48d541
Adjsut the tests to use the new cache data
SomeoneToIgnore Sep 9, 2025
29cd1ab
Fix initial tests
SomeoneToIgnore Sep 9, 2025
2aa54c0
Remove most of old inlay hints cache code
SomeoneToIgnore Sep 9, 2025
630ece5
Move inlay-related modules around
SomeoneToIgnore Sep 10, 2025
dabb3e2
One less TODO kb
SomeoneToIgnore Sep 10, 2025
03795bd
Restructure inlay responses
SomeoneToIgnore Sep 10, 2025
0c2dc73
It seems to work!
SomeoneToIgnore Sep 10, 2025
1fd6b24
Unify all LSP data into one struct
SomeoneToIgnore Sep 11, 2025
d414d9a
Now deduplicate requests by buffer chunks too
SomeoneToIgnore Sep 12, 2025
122cfa8
Return settings handling back
SomeoneToIgnore Sep 12, 2025
e3c9651
Remove special collab handling of proto::InlayHints
SomeoneToIgnore Sep 12, 2025
af070c9
Straighten the settings story a bit more
SomeoneToIgnore Sep 12, 2025
ae2266d
Rework inlay hint resolving
SomeoneToIgnore Sep 29, 2025
11a02bd
Post-rebase fixes
SomeoneToIgnore Sep 29, 2025
2748308
Do not re-insert existing inlay hints
SomeoneToIgnore Sep 30, 2025
789c90a
Use usize for inlay ids
SomeoneToIgnore Oct 1, 2025
7b76e5c
Stop using old unused code
SomeoneToIgnore Oct 1, 2025
53e1748
Filter out not needed inlay hints
SomeoneToIgnore Oct 1, 2025
b0f138f
Fix a test
SomeoneToIgnore Oct 1, 2025
84729da
More fixes to the hint toggle logic
SomeoneToIgnore Oct 3, 2025
eea9223
Consider server id when refreshing inlay hints
SomeoneToIgnore Oct 3, 2025
1ad8248
Fix another test
SomeoneToIgnore Oct 3, 2025
6aa57e3
Fix toggle test
SomeoneToIgnore Oct 3, 2025
9630441
Fix another test
SomeoneToIgnore Oct 3, 2025
ddc6450
Fix another test
SomeoneToIgnore Oct 6, 2025
29a5498
Fix another test
SomeoneToIgnore Oct 7, 2025
9f78a48
Fix another test
SomeoneToIgnore Oct 7, 2025
559c263
Almost fix the last test
SomeoneToIgnore Oct 7, 2025
39990b9
Have all inlay hints editor tests fixed
SomeoneToIgnore Oct 8, 2025
14261f5
Fix duplicate hints and panics in real Zed
SomeoneToIgnore Oct 8, 2025
48dff2a
Fix document colors test
SomeoneToIgnore Oct 8, 2025
f9d7427
Fix all the tests
SomeoneToIgnore Oct 8, 2025
ad63397
Fix another panic
SomeoneToIgnore Oct 8, 2025
f09b83c
Document inlay-related modules
SomeoneToIgnore Oct 9, 2025
e4e2f2b
Fix inlay hints toggling with modifiers
SomeoneToIgnore Oct 9, 2025
4ded709
Cleanup hint fetch error code
SomeoneToIgnore Oct 10, 2025
9a1f699
Simplify the return types
SomeoneToIgnore Oct 10, 2025
7ca61d2
Refactor hint fetching to avoid extra tasks for chunks
SomeoneToIgnore Oct 10, 2025
ed521fe
Simplify
SomeoneToIgnore Oct 11, 2025
560d34a
Do not excessively clear tasks
SomeoneToIgnore Oct 12, 2025
4f521d9
Group excerpts per buffer
SomeoneToIgnore Oct 13, 2025
562ceba
Do not query for hints if the buffer is not registered
SomeoneToIgnore Oct 13, 2025
5dcdd33
Fix the test, simplify the code
SomeoneToIgnore Oct 13, 2025
42dc028
Post-rebase fixes
SomeoneToIgnore Oct 13, 2025
49f1318
Remove another TODO
SomeoneToIgnore Oct 14, 2025
ccc0592
Fix the last TODO
SomeoneToIgnore Oct 14, 2025
128118f
Post-rebase fixes
SomeoneToIgnore Oct 14, 2025
562c691
Better invalidate editor inlay chunks
SomeoneToIgnore Oct 14, 2025
47d6fa3
Small fixes
SomeoneToIgnore Oct 14, 2025
a68aed9
Merge branch 'main' into kb/shared-inlays-2
SomeoneToIgnore Oct 16, 2025
43729bd
Fix the remaining tests
SomeoneToIgnore Oct 16, 2025
44ca338
Always update LSP data on buffer registration
SomeoneToIgnore Oct 17, 2025
2146d87
Merge branch 'main' into kb/shared-inlays-2
SomeoneToIgnore Oct 17, 2025
40af66d
Try to query each excerpt for inlays
SomeoneToIgnore Oct 17, 2025
222ada1
Fix the test
SomeoneToIgnore Oct 17, 2025
e6b5b82
Add new chunk hints to all existing excerpts in the multi buffer
SomeoneToIgnore Oct 17, 2025
153aa2a
Merge remote-tracking branch 'origin/main' into kb/shared-inlays-2
SomeoneToIgnore Oct 17, 2025
8783a9e
Add a failing test
SomeoneToIgnore Oct 18, 2025
f5188d5
Fix the bug
SomeoneToIgnore Oct 20, 2025
31cd2ef
Merge remote-tracking branch 'origin/main' into kb/shared-inlays-2
SomeoneToIgnore Oct 20, 2025
e695e46
Fix another multi buffer update bug
SomeoneToIgnore Oct 20, 2025
0372b4c
Properly deduplicate inlay hint fetch tasks
SomeoneToIgnore Oct 21, 2025
54f1005
Consider languages when updating visible excerpts' hints
SomeoneToIgnore Oct 21, 2025
e1714e4
Fix the final test
SomeoneToIgnore Oct 21, 2025
c13a6d5
Merge branch 'main' into kb/shared-inlays-2
SomeoneToIgnore Oct 21, 2025
69e854f
Uncomment fixed test
SomeoneToIgnore Oct 21, 2025
4f0c4f5
Return remote inlay resolving to the pre-refactoring state
SomeoneToIgnore Oct 21, 2025
53b2934
Merge branch 'main' into kb/shared-inlays-2
SomeoneToIgnore Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions crates/agent_ui/src/acp/message_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use assistant_slash_commands::codeblock_fence_for_path;
use collections::{HashMap, HashSet};
use editor::{
Addon, Anchor, AnchorRangeExt, ContextMenuOptions, ContextMenuPlacement, Editor, EditorElement,
EditorEvent, EditorMode, EditorSnapshot, EditorStyle, ExcerptId, FoldPlaceholder, InlayId,
EditorEvent, EditorMode, EditorSnapshot, EditorStyle, ExcerptId, FoldPlaceholder, Inlay,
MultiBuffer, ToOffset,
actions::Paste,
display_map::{Crease, CreaseId, FoldId, Inlay},
display_map::{Crease, CreaseId, FoldId},
};
use futures::{
FutureExt as _,
Expand All @@ -29,7 +29,8 @@ use language::{Buffer, Language, language_settings::InlayHintKind};
use language_model::LanguageModelImage;
use postage::stream::Stream as _;
use project::{
CompletionIntent, InlayHint, InlayHintLabel, Project, ProjectItem, ProjectPath, Worktree,
CompletionIntent, InlayHint, InlayHintLabel, InlayId, Project, ProjectItem, ProjectPath,
Worktree,
};
use prompt_store::{PromptId, PromptStore};
use rope::Point;
Expand Down Expand Up @@ -75,7 +76,7 @@ pub enum MessageEditorEvent {

impl EventEmitter<MessageEditorEvent> for MessageEditor {}

const COMMAND_HINT_INLAY_ID: u32 = 0;
const COMMAND_HINT_INLAY_ID: InlayId = InlayId::Hint(0);

impl MessageEditor {
pub fn new(
Expand Down Expand Up @@ -151,7 +152,7 @@ impl MessageEditor {
let has_new_hint = !new_hints.is_empty();
editor.splice_inlays(
if has_hint {
&[InlayId::Hint(COMMAND_HINT_INLAY_ID)]
&[COMMAND_HINT_INLAY_ID]
} else {
&[]
},
Expand Down
1 change: 0 additions & 1 deletion crates/collab/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@ impl Server {
.add_request_handler(forward_read_only_project_request::<proto::OpenBufferForSymbol>)
.add_request_handler(forward_read_only_project_request::<proto::OpenBufferById>)
.add_request_handler(forward_read_only_project_request::<proto::SynchronizeBuffers>)
.add_request_handler(forward_read_only_project_request::<proto::InlayHints>)
.add_request_handler(forward_read_only_project_request::<proto::ResolveInlayHint>)
.add_request_handler(forward_read_only_project_request::<proto::GetColorPresentation>)
.add_request_handler(forward_read_only_project_request::<proto::OpenBufferByPath>)
Expand Down
167 changes: 86 additions & 81 deletions crates/collab/src/tests/editor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1849,10 +1849,40 @@ async fn test_mutual_editor_inlay_hint_cache_update(
..lsp::ServerCapabilities::default()
};
client_a.language_registry().add(rust_lang());

// Set up the language server to return an additional inlay hint on each request.
let edits_made = Arc::new(AtomicUsize::new(0));
let closure_edits_made = Arc::clone(&edits_made);
let mut fake_language_servers = client_a.language_registry().register_fake_lsp(
"Rust",
FakeLspAdapter {
capabilities: capabilities.clone(),
initializer: Some(Box::new(move |fake_language_server| {
let closure_edits_made = closure_edits_made.clone();
fake_language_server.set_request_handler::<lsp::request::InlayHintRequest, _, _>(
move |params, _| {
let edits_made_2 = Arc::clone(&closure_edits_made);
async move {
assert_eq!(
params.text_document.uri,
lsp::Uri::from_file_path(path!("/a/main.rs")).unwrap(),
);
let edits_made =
AtomicUsize::load(&edits_made_2, atomic::Ordering::Acquire);
Ok(Some(vec![lsp::InlayHint {
position: lsp::Position::new(0, edits_made as u32),
label: lsp::InlayHintLabel::String(edits_made.to_string()),
kind: None,
text_edits: None,
tooltip: None,
padding_left: None,
padding_right: None,
data: None,
}]))
}
},
);
})),
..FakeLspAdapter::default()
},
);
Expand Down Expand Up @@ -1894,61 +1924,20 @@ async fn test_mutual_editor_inlay_hint_cache_update(
.unwrap();

let (workspace_a, cx_a) = client_a.build_workspace(&project_a, cx_a);
executor.start_waiting();

// The host opens a rust file.
let _buffer_a = project_a
.update(cx_a, |project, cx| {
project.open_local_buffer(path!("/a/main.rs"), cx)
})
.await
.unwrap();
let editor_a = workspace_a
.update_in(cx_a, |workspace, window, cx| {
workspace.open_path((worktree_id, rel_path("main.rs")), None, true, window, cx)
})
.await
.unwrap()
.downcast::<Editor>()
.unwrap();

let file_a = workspace_a.update_in(cx_a, |workspace, window, cx| {
workspace.open_path((worktree_id, rel_path("main.rs")), None, true, window, cx)
});
let fake_language_server = fake_language_servers.next().await.unwrap();

// Set up the language server to return an additional inlay hint on each request.
let edits_made = Arc::new(AtomicUsize::new(0));
let closure_edits_made = Arc::clone(&edits_made);
fake_language_server
.set_request_handler::<lsp::request::InlayHintRequest, _, _>(move |params, _| {
let edits_made_2 = Arc::clone(&closure_edits_made);
async move {
assert_eq!(
params.text_document.uri,
lsp::Uri::from_file_path(path!("/a/main.rs")).unwrap(),
);
let edits_made = AtomicUsize::load(&edits_made_2, atomic::Ordering::Acquire);
Ok(Some(vec![lsp::InlayHint {
position: lsp::Position::new(0, edits_made as u32),
label: lsp::InlayHintLabel::String(edits_made.to_string()),
kind: None,
text_edits: None,
tooltip: None,
padding_left: None,
padding_right: None,
data: None,
}]))
}
})
.next()
.await
.unwrap();

let editor_a = file_a.await.unwrap().downcast::<Editor>().unwrap();
executor.run_until_parked();

let initial_edit = edits_made.load(atomic::Ordering::Acquire);
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert_eq!(
vec![initial_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Host should get its first hints when opens an editor"
);
});
Expand All @@ -1963,10 +1952,10 @@ async fn test_mutual_editor_inlay_hint_cache_update(
.unwrap();

executor.run_until_parked();
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec![initial_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Client should get its first hints when opens an editor"
);
});
Expand All @@ -1981,16 +1970,16 @@ async fn test_mutual_editor_inlay_hint_cache_update(
cx_b.focus(&editor_b);

executor.run_until_parked();
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert_eq!(
vec![after_client_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
);
});
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec![after_client_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
);
});

Expand All @@ -2004,16 +1993,16 @@ async fn test_mutual_editor_inlay_hint_cache_update(
cx_a.focus(&editor_a);

executor.run_until_parked();
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert_eq!(
vec![after_host_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
);
});
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec![after_host_edit.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
);
});

Expand All @@ -2025,26 +2014,22 @@ async fn test_mutual_editor_inlay_hint_cache_update(
.expect("inlay refresh request failed");

executor.run_until_parked();
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert_eq!(
vec![after_special_edit_for_refresh.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Host should react to /refresh LSP request"
);
});
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec![after_special_edit_for_refresh.to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Guest should get a /refresh LSP request propagated by host"
);
});
}

// This test started hanging on seed 2 after the theme settings
// PR. The hypothesis is that it's been buggy for a while, but got lucky
// on seeds.
#[ignore]
#[gpui::test(iterations = 10)]
async fn test_inlay_hint_refresh_is_forwarded(
cx_a: &mut TestAppContext,
Expand Down Expand Up @@ -2206,18 +2191,18 @@ async fn test_inlay_hint_refresh_is_forwarded(
executor.finish_waiting();

executor.run_until_parked();
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert!(
extract_hint_labels(editor).is_empty(),
extract_hint_labels(editor, cx).is_empty(),
"Host should get no hints due to them turned off"
);
});

executor.run_until_parked();
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec!["initial hint".to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Client should get its first hints when opens an editor"
);
});
Expand All @@ -2229,18 +2214,18 @@ async fn test_inlay_hint_refresh_is_forwarded(
.into_response()
.expect("inlay refresh request failed");
executor.run_until_parked();
editor_a.update(cx_a, |editor, _| {
editor_a.update(cx_a, |editor, cx| {
assert!(
extract_hint_labels(editor).is_empty(),
extract_hint_labels(editor, cx).is_empty(),
"Host should get no hints due to them turned off, even after the /refresh"
);
});

executor.run_until_parked();
editor_b.update(cx_b, |editor, _| {
editor_b.update(cx_b, |editor, cx| {
assert_eq!(
vec!["other hint".to_string()],
extract_hint_labels(editor),
extract_hint_labels(editor, cx),
"Guest should get a /refresh LSP request propagated by host despite host hints are off"
);
});
Expand Down Expand Up @@ -4217,15 +4202,35 @@ fn tab_undo_assert(
cx_b.assert_editor_state(expected_initial);
}

fn extract_hint_labels(editor: &Editor) -> Vec<String> {
let mut labels = Vec::new();
for hint in editor.inlay_hint_cache().hints() {
match hint.label {
project::InlayHintLabel::String(s) => labels.push(s),
_ => unreachable!(),
}
fn extract_hint_labels(editor: &Editor, cx: &mut App) -> Vec<String> {
let lsp_store = editor.project().unwrap().read(cx).lsp_store();

let mut all_cached_labels = Vec::new();
let mut all_fetched_hints = Vec::new();
for buffer in editor.buffer().read(cx).all_buffers() {
lsp_store.update(cx, |lsp_store, cx| {
let hints = &lsp_store.latest_lsp_data(&buffer, cx).inlay_hints();
all_cached_labels.extend(hints.all_cached_hints().into_iter().map(|hint| {
let mut label = hint.text().to_string();
if hint.padding_left {
label.insert(0, ' ');
}
if hint.padding_right {
label.push_str(" ");
}
label
}));
all_fetched_hints.extend(hints.all_fetched_hints());
});
}
labels

assert!(
all_fetched_hints.is_empty(),
"Did not expect background hints fetch tasks, but got {} of them",
all_fetched_hints.len()
);

all_cached_labels
}

#[track_caller]
Expand Down
4 changes: 2 additions & 2 deletions crates/diagnostics/src/diagnostics_tests.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::*;
use collections::{HashMap, HashSet};
use editor::{
DisplayPoint, EditorSettings,
DisplayPoint, EditorSettings, Inlay,
actions::{GoToDiagnostic, GoToPreviousDiagnostic, Hover, MoveToBeginning},
display_map::{DisplayRow, Inlay},
display_map::DisplayRow,
test::{
editor_content_with_blocks, editor_lsp_test_context::EditorLspTestContext,
editor_test_context::EditorTestContext,
Expand Down
Loading
Loading