Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 6 additions & 39 deletions crates/editor/src/editor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ use util::{
};
use workspace::{
CloseActiveItem, CloseAllItems, CloseOtherItems, MultiWorkspace, NavigationEntry, OpenOptions,
ViewId, Workspace,
ViewId,
item::{FollowEvent, FollowableItem, Item, ItemHandle, SaveOptions},
register_project_item,
};
Expand Down Expand Up @@ -12296,9 +12296,6 @@ async fn test_multibuffer_format_during_save(cx: &mut TestAppContext) {

let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);

let language_registry = project.read_with(cx, |project, _| project.languages().clone());
Expand Down Expand Up @@ -12498,9 +12495,6 @@ async fn test_autosave_with_dirty_buffers(cx: &mut TestAppContext) {

let project = Project::test(fs.clone(), [path!("/dir").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);

let language_registry = project.read_with(cx, |project, _| project.languages().clone());
Expand Down Expand Up @@ -23518,9 +23512,6 @@ async fn test_find_enclosing_node_with_task(cx: &mut TestAppContext) {

let project = Project::test(fs, ["/a".as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);
let buffer = cx.new(|cx| Buffer::local(text, cx).with_language(language, cx));
let multi_buffer = cx.new(|cx| MultiBuffer::singleton(buffer.clone(), cx));
Expand Down Expand Up @@ -23594,9 +23585,6 @@ async fn test_folding_buffers(cx: &mut TestAppContext) {
.await;
let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);
let worktree = project.update(cx, |project, cx| {
let mut worktrees = project.worktrees(cx).collect::<Vec<_>>();
Expand Down Expand Up @@ -23765,9 +23753,6 @@ async fn test_folding_buffers_with_one_excerpt(cx: &mut TestAppContext) {
.await;
let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);
let worktree = project.update(cx, |project, cx| {
let mut worktrees = project.worktrees(cx).collect::<Vec<_>>();
Expand Down Expand Up @@ -23903,9 +23888,6 @@ async fn test_folding_buffer_when_multibuffer_has_only_one_excerpt(cx: &mut Test
.await;
let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);
let worktree = project.update(cx, |project, cx| {
let mut worktrees = project.worktrees(cx).collect::<Vec<_>>();
Expand Down Expand Up @@ -24432,9 +24414,6 @@ async fn test_breakpoint_toggling(cx: &mut TestAppContext) {
.await;
let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);

let fs = FakeFs::new(cx.executor());
Expand Down Expand Up @@ -24721,9 +24700,6 @@ async fn test_breakpoint_enabling_and_disabling(cx: &mut TestAppContext) {
.await;
let project = Project::test(fs, [path!("/a").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);

let fs = FakeFs::new(cx.executor());
Expand Down Expand Up @@ -25245,7 +25221,7 @@ async fn test_apply_code_lens_actions_with_commands(cx: &mut gpui::TestAppContex
let anchor = buffer_snapshot.anchor_at(0, text::Bias::Left);
drop(buffer_snapshot);
let actions = cx
.update_window(*workspace, |_, window, cx| {
.update_window(*window, |_, window, cx| {
project.code_actions(&buffer, anchor..anchor, window, cx)
})
.unwrap();
Expand Down Expand Up @@ -25370,12 +25346,9 @@ async fn test_apply_code_lens_actions_with_commands(cx: &mut gpui::TestAppContex
});

let actions_after_edits = cx
.update_window(*workspace, |_, window, cx| {
project.code_actions(&buffer, anchor..anchor, window, cx)
})
.update(|window, cx| project.code_actions(&buffer, anchor..anchor, window, cx))
.unwrap()
.await
.unwrap();
.await;
assert_eq!(
actions, actions_after_edits,
"For the same selection, same code lens actions should be returned"
Expand All @@ -25390,12 +25363,9 @@ async fn test_apply_code_lens_actions_with_commands(cx: &mut gpui::TestAppContex
});
cx.executor().run_until_parked();
let new_actions = cx
.update_window(*workspace, |_, window, cx| {
project.code_actions(&buffer, anchor..anchor, window, cx)
})
.update(|window, cx| project.code_actions(&buffer, anchor..anchor, window, cx))
.unwrap()
.await
.unwrap();
.await;
assert_eq!(
actions, new_actions,
"Code lens are queried for the same range and should get the same set back, but without additional LSP queries now"
Expand Down Expand Up @@ -28778,9 +28748,6 @@ async fn test_race_in_multibuffer_save(cx: &mut TestAppContext) {

let project = Project::test(fs, [path!("/project").as_ref()], cx).await;
let window = cx.add_window(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = window
.read_with(cx, |mw, _| mw.workspace().clone())
.unwrap();
let cx = &mut VisualTestContext::from_window(*window, cx);

let language = rust_lang();
Expand Down
4 changes: 2 additions & 2 deletions crates/editor/src/items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ use text::{BufferId, BufferSnapshot, Selection};
use ui::{IconDecorationKind, prelude::*};
use util::{ResultExt, TryFutureExt, paths::PathExt};
use workspace::{
CollaboratorId, ItemId, ItemNavHistory, MultiWorkspace, ToolbarItemLocation, ViewId, Workspace,
WorkspaceId,
CollaboratorId, ItemId, ItemNavHistory, ToolbarItemLocation, ViewId, Workspace, WorkspaceId,
invalid_item_view::InvalidItemView,
item::{FollowableItem, Item, ItemBufferKind, ItemEvent, ProjectItem, SaveOptions},
searchable::{
Expand Down Expand Up @@ -2007,6 +2006,7 @@ fn restore_serialized_buffer_contents(
mod tests {
use crate::editor_tests::init_test;
use fs::Fs;
use workspace::MultiWorkspace;

use super::*;
use fs::MTime;
Expand Down
58 changes: 28 additions & 30 deletions crates/editor/src/semantic_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,7 @@ mod tests {
};

use futures::StreamExt as _;
use gpui::{
AppContext as _, Entity, Focusable as _, HighlightStyle, TestAppContext, VisualTestContext,
};
use gpui::{AppContext as _, Entity, Focusable as _, HighlightStyle, TestAppContext};
use language::{Language, LanguageConfig, LanguageMatcher};
use languages::FakeLspAdapter;
use multi_buffer::{
Expand All @@ -430,7 +428,7 @@ mod tests {
use rope::Point;
use serde_json::json;
use settings::{LanguageSettingsContent, SemanticTokenRules, SemanticTokens, SettingsStore};
use workspace::{MultiWorkspace, Workspace, WorkspaceHandle as _};
use workspace::{MultiWorkspace, WorkspaceHandle as _};

use crate::{
Capability,
Expand Down Expand Up @@ -850,11 +848,11 @@ mod tests {
)
.await;

let (multi_workspace, mut cx) =
let (multi_workspace, cx) =
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = multi_workspace.read_with(&cx, |mw, _| mw.workspace().clone());
let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone());
project
.update(&mut cx, |project, cx| {
.update(cx, |project, cx| {
project.find_or_create_worktree(EditorLspTestContext::root_path(), true, cx)
})
.await
Expand All @@ -864,7 +862,7 @@ mod tests {

let toml_file = cx.read(|cx| workspace.file_project_paths(cx)[0].clone());
let toml_item = workspace
.update_in(&mut cx, |workspace, window, cx| {
.update_in(cx, |workspace, window, cx| {
workspace.open_path(toml_file, None, true, window, cx)
})
.await
Expand All @@ -876,7 +874,7 @@ mod tests {
.expect("Opened test file wasn't an editor")
});

editor.update_in(&mut cx, |editor, window, cx| {
editor.update_in(cx, |editor, window, cx| {
let nav_history = workspace
.read(cx)
.active_pane()
Expand All @@ -890,11 +888,11 @@ mod tests {
let _toml_server_2 = toml_server_2.next().await.unwrap();

// Trigger semantic tokens.
editor.update_in(&mut cx, |editor, _, cx| {
editor.update_in(cx, |editor, _, cx| {
editor.edit([(MultiBufferOffset(0)..MultiBufferOffset(1), "b")], cx);
});
cx.executor().advance_clock(Duration::from_millis(200));
let task = editor.update_in(&mut cx, |e, _, _| e.semantic_token_state.take_update_task());
let task = editor.update_in(cx, |e, _, _| e.semantic_token_state.take_update_task());
cx.run_until_parked();
task.await;

Expand Down Expand Up @@ -1069,11 +1067,11 @@ mod tests {
)
.await;

let (multi_workspace, mut cx) =
let (multi_workspace, cx) =
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = multi_workspace.read_with(&cx, |mw, _| mw.workspace().clone());
let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone());
project
.update(&mut cx, |project, cx| {
.update(cx, |project, cx| {
project.find_or_create_worktree(EditorLspTestContext::root_path(), true, cx)
})
.await
Expand All @@ -1083,7 +1081,7 @@ mod tests {

let toml_file = cx.read(|cx| workspace.file_project_paths(cx)[1].clone());
let rust_file = cx.read(|cx| workspace.file_project_paths(cx)[0].clone());
let (toml_item, rust_item) = workspace.update_in(&mut cx, |workspace, window, cx| {
let (toml_item, rust_item) = workspace.update_in(cx, |workspace, window, cx| {
(
workspace.open_path(toml_file, None, true, window, cx),
workspace.open_path(rust_file, None, true, window, cx),
Expand Down Expand Up @@ -1133,12 +1131,12 @@ mod tests {
multibuffer
});

let editor = workspace.update_in(&mut cx, |workspace, window, cx| {
let editor = workspace.update_in(cx, |workspace, window, cx| {
let editor = cx.new(|cx| build_editor_with_project(project, multibuffer, window, cx));
workspace.add_item_to_active_pane(Box::new(editor.clone()), None, true, window, cx);
editor
});
editor.update_in(&mut cx, |editor, window, cx| {
editor.update_in(cx, |editor, window, cx| {
let nav_history = workspace
.read(cx)
.active_pane()
Expand All @@ -1153,7 +1151,7 @@ mod tests {

// Initial request.
cx.executor().advance_clock(Duration::from_millis(200));
let task = editor.update_in(&mut cx, |e, _, _| e.semantic_token_state.take_update_task());
let task = editor.update_in(cx, |e, _, _| e.semantic_token_state.take_update_task());
cx.run_until_parked();
task.await;
assert_eq!(full_counter_toml.load(atomic::Ordering::Acquire), 1);
Expand All @@ -1168,16 +1166,16 @@ mod tests {

// Get the excerpt id for the TOML excerpt and expand it down by 2 lines.
let toml_excerpt_id =
editor.read_with(&cx, |editor, cx| editor.buffer().read(cx).excerpt_ids()[0]);
editor.update_in(&mut cx, |editor, _, cx| {
editor.read_with(cx, |editor, cx| editor.buffer().read(cx).excerpt_ids()[0]);
editor.update_in(cx, |editor, _, cx| {
editor.buffer().update(cx, |buffer, cx| {
buffer.expand_excerpts([toml_excerpt_id], 2, ExpandExcerptDirection::Down, cx);
});
});

// Wait for semantic tokens to be re-fetched after expansion.
cx.executor().advance_clock(Duration::from_millis(200));
let task = editor.update_in(&mut cx, |e, _, _| e.semantic_token_state.take_update_task());
let task = editor.update_in(cx, |e, _, _| e.semantic_token_state.take_update_task());
cx.run_until_parked();
task.await;

Expand Down Expand Up @@ -1300,11 +1298,11 @@ mod tests {
)
.await;

let (multi_workspace, mut cx) =
let (multi_workspace, cx) =
cx.add_window_view(|window, cx| MultiWorkspace::test_new(project.clone(), window, cx));
let workspace = multi_workspace.read_with(&cx, |mw, _| mw.workspace().clone());
let workspace = multi_workspace.read_with(cx, |mw, _| mw.workspace().clone());
project
.update(&mut cx, |project, cx| {
.update(cx, |project, cx| {
project.find_or_create_worktree(EditorLspTestContext::root_path(), true, cx)
})
.await
Expand All @@ -1314,7 +1312,7 @@ mod tests {

let toml_file = cx.read(|cx| workspace.file_project_paths(cx)[0].clone());
let toml_item = workspace
.update_in(&mut cx, |workspace, window, cx| {
.update_in(cx, |workspace, window, cx| {
workspace.open_path(toml_file, None, true, window, cx)
})
.await
Expand Down Expand Up @@ -1348,10 +1346,10 @@ mod tests {
multibuffer
});

let editor = workspace.update_in(&mut cx, |_, window, cx| {
let editor = workspace.update_in(cx, |_, window, cx| {
cx.new(|cx| build_editor_with_project(project, multibuffer, window, cx))
});
editor.update_in(&mut cx, |editor, window, cx| {
editor.update_in(cx, |editor, window, cx| {
let nav_history = workspace
.read(cx)
.active_pane()
Expand All @@ -1365,7 +1363,7 @@ mod tests {

// Initial request.
cx.executor().advance_clock(Duration::from_millis(200));
let task = editor.update_in(&mut cx, |e, _, _| e.semantic_token_state.take_update_task());
let task = editor.update_in(cx, |e, _, _| e.semantic_token_state.take_update_task());
cx.run_until_parked();
task.await;
assert_eq!(full_counter_toml.load(atomic::Ordering::Acquire), 1);
Expand All @@ -1374,12 +1372,12 @@ mod tests {
//
// Without debouncing, this grabs semantic tokens 4 times (twice for the
// toml editor, and twice for the multibuffer).
editor.update_in(&mut cx, |editor, _, cx| {
editor.update_in(cx, |editor, _, cx| {
editor.edit([(MultiBufferOffset(0)..MultiBufferOffset(1), "b")], cx);
editor.edit([(MultiBufferOffset(12)..MultiBufferOffset(13), "c")], cx);
});
cx.executor().advance_clock(Duration::from_millis(200));
let task = editor.update_in(&mut cx, |e, _, _| e.semantic_token_state.take_update_task());
let task = editor.update_in(cx, |e, _, _| e.semantic_token_state.take_update_task());
cx.run_until_parked();
task.await;
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion crates/editor/src/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,7 +2012,7 @@ mod tests {
use rand::rngs::StdRng;
use settings::{DiffViewStyle, SettingsStore};
use ui::{VisualContext as _, div, px};
use workspace::{MultiWorkspace, Workspace};
use workspace::MultiWorkspace;

use crate::SplittableEditor;
use crate::display_map::{BlockPlacement, BlockProperties, BlockStyle};
Expand Down
Loading