diff --git a/crates/copilot_button2/src/copilot_button.rs b/crates/copilot_button2/src/copilot_button.rs index d3a1c1e58c0e6e0113cc965017aecf0a3c3cdca9..2c8427732e7043da64aa16b6e72547678f4d82df 100644 --- a/crates/copilot_button2/src/copilot_button.rs +++ b/crates/copilot_button2/src/copilot_button.rs @@ -1,11 +1,10 @@ -#![allow(unused)] use anyhow::Result; use copilot::{Copilot, SignOut, Status}; use editor::{scroll::autoscroll::Autoscroll, Editor}; use fs::Fs; use gpui::{ - div, Action, AnchorCorner, AppContext, AsyncAppContext, AsyncWindowContext, Div, Entity, - ParentElement, Render, Subscription, View, ViewContext, WeakView, WindowContext, + div, Action, AnchorCorner, AppContext, AsyncWindowContext, Div, Entity, ParentElement, Render, + Subscription, View, ViewContext, WeakView, WindowContext, }; use language::{ language_settings::{self, all_language_settings, AllLanguageSettings}, @@ -17,10 +16,7 @@ use util::{paths, ResultExt}; use workspace::{ create_and_open_local_file, item::ItemHandle, - ui::{ - popover_menu, ButtonCommon, Clickable, ContextMenu, Icon, IconButton, IconSize, - PopoverMenu, Tooltip, - }, + ui::{popover_menu, ButtonCommon, Clickable, ContextMenu, Icon, IconButton, IconSize, Tooltip}, StatusItemView, Toast, Workspace, }; use zed_actions::OpenBrowser; @@ -71,27 +67,31 @@ impl Render for CopilotButton { return div().child( IconButton::new("copilot-error", icon) .icon_size(IconSize::Small) - .on_click(cx.listener(move |this, _, cx| { + .on_click(cx.listener(move |_, _, cx| { if let Some(workspace) = cx.window_handle().downcast::() { - workspace.update(cx, |workspace, cx| { - workspace.show_toast( - Toast::new( - COPILOT_ERROR_TOAST_ID, - format!("Copilot can't be started: {}", e), - ) - .on_click( - "Reinstall Copilot", - |cx| { - if let Some(copilot) = Copilot::global(cx) { - copilot - .update(cx, |copilot, cx| copilot.reinstall(cx)) - .detach(); - } - }, - ), - cx, - ); - }); + workspace + .update(cx, |workspace, cx| { + workspace.show_toast( + Toast::new( + COPILOT_ERROR_TOAST_ID, + format!("Copilot can't be started: {}", e), + ) + .on_click( + "Reinstall Copilot", + |cx| { + if let Some(copilot) = Copilot::global(cx) { + copilot + .update(cx, |copilot, cx| { + copilot.reinstall(cx) + }) + .detach(); + } + }, + ), + cx, + ); + }) + .ok(); } })) .tooltip(|cx| Tooltip::text("GitHub Copilot", cx)), @@ -134,7 +134,7 @@ impl CopilotButton { pub fn build_copilot_start_menu(&mut self, cx: &mut ViewContext) -> View { let fs = self.fs.clone(); - ContextMenu::build(cx, |menu, cx| { + ContextMenu::build(cx, |menu, _| { menu.entry("Sign In", None, initiate_sign_in).entry( "Disable Copilot", None, diff --git a/crates/editor2/src/blink_manager.rs b/crates/editor2/src/blink_manager.rs index 0fc748f48abbcaf66e47f9ab86dcfd4855a20e3d..e3a8ce6293c67a57af4a4a2403e074cfd9765344 100644 --- a/crates/editor2/src/blink_manager.rs +++ b/crates/editor2/src/blink_manager.rs @@ -67,7 +67,8 @@ impl BlinkManager { cx.spawn(|this, mut cx| async move { Timer::after(interval).await; if let Some(this) = this.upgrade() { - this.update(&mut cx, |this, cx| this.blink_cursors(epoch, cx)); + this.update(&mut cx, |this, cx| this.blink_cursors(epoch, cx)) + .ok(); } }) .detach(); diff --git a/crates/editor2/src/display_map.rs b/crates/editor2/src/display_map.rs index 60975a7a5caec6552b3154e528b9629e9beb094c..6298c80d2f05c1e9fddaa2149be1553e2ea14f8f 100644 --- a/crates/editor2/src/display_map.rs +++ b/crates/editor2/src/display_map.rs @@ -12,10 +12,7 @@ use crate::{ pub use block_map::{BlockMap, BlockPoint}; use collections::{BTreeMap, HashMap, HashSet}; use fold_map::FoldMap; -use gpui::{ - Font, FontId, HighlightStyle, Hsla, LineLayout, Model, ModelContext, Pixels, ShapedLine, - TextRun, UnderlineStyle, WrappedLine, -}; +use gpui::{Font, HighlightStyle, Hsla, LineLayout, Model, ModelContext, Pixels, UnderlineStyle}; use inlay_map::InlayMap; use language::{ language_settings::language_settings, OffsetUtf16, Point, Subscription as BufferSubscription, @@ -24,7 +21,7 @@ use lsp::DiagnosticSeverity; use std::{any::TypeId, borrow::Cow, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc}; use sum_tree::{Bias, TreeMap}; use tab_map::TabMap; -use theme::{StatusColors, SyntaxTheme, Theme}; + use wrap_map::WrapMap; pub use block_map::{ @@ -1018,7 +1015,7 @@ pub mod tests { .map(|i| i.parse().expect("invalid `OPERATIONS` variable")) .unwrap_or(10); - let test_platform = &cx.test_platform; + let _test_platform = &cx.test_platform; let mut tab_size = rng.gen_range(1..=4); let buffer_start_excerpt_header_height = rng.gen_range(1..=5); let excerpt_header_height = rng.gen_range(1..=5); @@ -1280,7 +1277,7 @@ pub mod tests { let editor = cx.editor.clone(); let window = cx.window.clone(); - cx.update_window(window, |_, cx| { + _ = cx.update_window(window, |_, cx| { let text_layout_details = editor.update(cx, |editor, cx| editor.text_layout_details(cx)); diff --git a/crates/editor2/src/display_map/block_map.rs b/crates/editor2/src/display_map/block_map.rs index cc0095bca94f30f6d65866c640092cb384d2cce3..6eb0d05bfe84c4b487bb65bfc97ee49bcaff1736 100644 --- a/crates/editor2/src/display_map/block_map.rs +++ b/crates/editor2/src/display_map/block_map.rs @@ -1185,7 +1185,7 @@ mod tests { fn test_blocks_on_wrapped_lines(cx: &mut gpui::TestAppContext) { cx.update(|cx| init_test(cx)); - let font_id = cx.text_system().font_id(&font("Helvetica")).unwrap(); + let _font_id = cx.text_system().font_id(&font("Helvetica")).unwrap(); let text = "one two three\nfour five six\nseven eight"; diff --git a/crates/editor2/src/display_map/wrap_map.rs b/crates/editor2/src/display_map/wrap_map.rs index 6a47a435a3c445d87b811c790bb4d83a1523983a..4ef6a13c69ed81b8e4a6c6a23bd19d0b94391642 100644 --- a/crates/editor2/src/display_map/wrap_map.rs +++ b/crates/editor2/src/display_map/wrap_map.rs @@ -197,7 +197,8 @@ impl WrapMap { this.background_task = None; this.flush_edits(cx); cx.notify(); - }); + }) + .ok(); })); } } @@ -277,7 +278,8 @@ impl WrapMap { this.background_task = None; this.flush_edits(cx); cx.notify(); - }); + }) + .ok(); })); } } @@ -1057,7 +1059,7 @@ mod tests { }; let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap(); let font = font("Helvetica"); - let font_id = text_system.font_id(&font).unwrap(); + let _font_id = text_system.font_id(&font).unwrap(); let font_size = px(14.0); log::info!("Tab size: {}", tab_size); diff --git a/crates/editor2/src/editor.rs b/crates/editor2/src/editor.rs index d3ee41b11f92512a88c6b6dc334256aacc8625aa..c9fb2fa181f4a1d9d06cfcb21e95c7bbd2c4c34a 100644 --- a/crates/editor2/src/editor.rs +++ b/crates/editor2/src/editor.rs @@ -1,4 +1,3 @@ -#![allow(unused)] mod blink_manager; pub mod display_map; mod editor_settings; @@ -42,11 +41,10 @@ use git::diff_hunk_to_display; use gpui::{ actions, div, impl_actions, point, prelude::*, px, relative, rems, size, uniform_list, Action, AnyElement, AppContext, AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Context, - DispatchPhase, Div, ElementId, EventEmitter, FocusHandle, FocusableView, FontFeatures, - FontStyle, FontWeight, HighlightStyle, Hsla, InputHandler, InteractiveText, KeyContext, Model, - MouseButton, ParentElement, Pixels, Render, RenderOnce, SharedString, Styled, StyledText, - Subscription, Task, TextRun, TextStyle, UniformListScrollHandle, View, ViewContext, - VisualContext, WeakView, WhiteSpace, WindowContext, + DispatchPhase, ElementId, EventEmitter, FocusHandle, FocusableView, FontStyle, FontWeight, + HighlightStyle, Hsla, InputHandler, InteractiveText, KeyContext, Model, MouseButton, + ParentElement, Pixels, Render, SharedString, Styled, StyledText, Subscription, Task, TextStyle, + UniformListScrollHandle, View, ViewContext, VisualContext, WeakView, WhiteSpace, WindowContext, }; use highlight_matching_bracket::refresh_matching_bracket_highlights; use hover_popover::{hide_hover, HoverState}; @@ -61,7 +59,7 @@ use language::{ LanguageRegistry, LanguageServerName, OffsetRangeExt, Point, Selection, SelectionGoal, TransactionId, }; -use lazy_static::lazy_static; + use link_go_to_definition::{GoToDefinitionLink, InlayHighlight, LinkGoToDefinitionState}; use lsp::{DiagnosticSeverity, LanguageServerId}; use mouse_context_menu::MouseContextMenu; @@ -72,7 +70,7 @@ pub use multi_buffer::{ ToPoint, }; use ordered_float::OrderedFloat; -use parking_lot::{Mutex, RwLock}; +use parking_lot::RwLock; use project::{FormatTrigger, Location, Project, ProjectPath, ProjectTransaction}; use rand::prelude::*; use rpc::proto::{self, *}; @@ -99,19 +97,11 @@ use std::{ pub use sum_tree::Bias; use sum_tree::TreeMap; use text::{OffsetUtf16, Rope}; -use theme::{ - ActiveTheme, DiagnosticStyle, PlayerColor, SyntaxTheme, Theme, ThemeColors, ThemeSettings, -}; -use ui::{ - h_stack, v_stack, ButtonSize, ButtonStyle, HighlightedLabel, Icon, IconButton, Popover, Tooltip, -}; +use theme::{ActiveTheme, DiagnosticStyle, PlayerColor, SyntaxTheme, ThemeColors, ThemeSettings}; +use ui::{h_stack, ButtonSize, ButtonStyle, Icon, IconButton, Popover, Tooltip}; use ui::{prelude::*, IconSize}; use util::{post_inc, RangeExt, ResultExt, TryFutureExt}; -use workspace::{ - item::{Item, ItemEvent, ItemHandle}, - searchable::SearchEvent, - ItemNavHistory, Pane, SplitDirection, ViewId, Workspace, -}; +use workspace::{searchable::SearchEvent, ItemNavHistory, Pane, SplitDirection, ViewId, Workspace}; const CURSOR_BLINK_INTERVAL: Duration = Duration::from_millis(500); const MAX_LINE_LEN: usize = 1024; @@ -439,7 +429,7 @@ pub fn init(cx: &mut AppContext) { workspace::register_followable_item::(cx); workspace::register_deserializable_item::(cx); cx.observe_new_views( - |workspace: &mut Workspace, cx: &mut ViewContext| { + |workspace: &mut Workspace, _cx: &mut ViewContext| { workspace.register_action(Editor::new_file); workspace.register_action(Editor::new_file_in_direction); }, @@ -1216,7 +1206,7 @@ impl CompletionsMenu { cx.view().clone(), "completions", matches.len(), - move |editor, range, cx| { + move |_editor, range, cx| { let start_ix = range.start; let completions_guard = completions.read(); @@ -1271,7 +1261,7 @@ impl CompletionsMenu { }) .on_mouse_down( MouseButton::Left, - cx.listener(move |editor, event, cx| { + cx.listener(move |editor, _event, cx| { cx.stop_propagation(); editor .confirm_completion( @@ -1414,7 +1404,7 @@ impl CodeActionsMenu { fn render( &self, mut cursor_position: DisplayPoint, - style: &EditorStyle, + _style: &EditorStyle, max_height: Pixels, cx: &mut ViewContext, ) -> (DisplayPoint, AnyElement) { @@ -1425,7 +1415,7 @@ impl CodeActionsMenu { cx.view().clone(), "code_actions_menu", self.actions.len(), - move |this, range, cx| { + move |_this, range, cx| { actions[range.clone()] .iter() .enumerate() @@ -3418,9 +3408,11 @@ impl Editor { Some(cx.spawn(|editor, mut cx| async move { if let Some(transaction) = on_type_formatting.await? { if push_to_client_history { - buffer.update(&mut cx, |buffer, _| { - buffer.push_transaction(transaction, Instant::now()); - }); + buffer + .update(&mut cx, |buffer, _| { + buffer.push_transaction(transaction, Instant::now()); + }) + .ok(); } editor.update(&mut cx, |editor, cx| { editor.refresh_document_highlights(cx); @@ -4226,7 +4218,7 @@ impl Editor { pub fn render_code_actions_indicator( &self, - style: &EditorStyle, + _style: &EditorStyle, is_active: bool, cx: &mut ViewContext, ) -> Option { @@ -4236,7 +4228,7 @@ impl Editor { .icon_size(IconSize::Small) .icon_color(Color::Muted) .selected(is_active) - .on_click(cx.listener(|editor, e, cx| { + .on_click(cx.listener(|editor, _e, cx| { editor.toggle_code_actions( &ToggleCodeActions { deployed_from_indicator: true, @@ -4253,10 +4245,10 @@ impl Editor { pub fn render_fold_indicators( &self, fold_data: Vec>, - style: &EditorStyle, + _style: &EditorStyle, gutter_hovered: bool, - line_height: Pixels, - gutter_margin: Pixels, + _line_height: Pixels, + _gutter_margin: Pixels, cx: &mut ViewContext, ) -> Vec> { fold_data @@ -4267,7 +4259,7 @@ impl Editor { .map(|(fold_status, buffer_row, active)| { (active || gutter_hovered || fold_status == FoldStatus::Folded).then(|| { IconButton::new(ix as usize, ui::Icon::ChevronDown) - .on_click(cx.listener(move |editor, e, cx| match fold_status { + .on_click(cx.listener(move |editor, _e, cx| match fold_status { FoldStatus::Folded => { editor.unfold_at(&UnfoldAt { buffer_row }, cx); } @@ -7379,11 +7371,13 @@ impl Editor { .filter_map(|location| location.transpose()) .collect::>() .context("location tasks")?; - workspace.update(&mut cx, |workspace, cx| { - Self::open_locations_in_multibuffer( - workspace, locations, replica_id, title, split, cx, - ) - }); + workspace + .update(&mut cx, |workspace, cx| { + Self::open_locations_in_multibuffer( + workspace, locations, replica_id, title, split, cx, + ) + }) + .ok(); anyhow::Ok(()) }) @@ -7832,15 +7826,17 @@ impl Editor { transaction = format.log_err().fuse() => transaction, }; - buffer.update(&mut cx, |buffer, cx| { - if let Some(transaction) = transaction { - if !buffer.is_singleton() { - buffer.push_transaction(&transaction.0, cx); + buffer + .update(&mut cx, |buffer, cx| { + if let Some(transaction) = transaction { + if !buffer.is_singleton() { + buffer.push_transaction(&transaction.0, cx); + } } - } - cx.notify(); - }); + cx.notify(); + }) + .ok(); Ok(()) }) @@ -9119,7 +9115,7 @@ impl Editor { let listener = Arc::new(listener); self.editor_actions.push(Box::new(move |cx| { - let view = cx.view().clone(); + let _view = cx.view().clone(); let cx = cx.window_context(); let listener = listener.clone(); cx.on_action(TypeId::of::(), move |action, phase, cx| { @@ -9289,7 +9285,7 @@ pub enum EditorEvent { impl EventEmitter for Editor {} impl FocusableView for Editor { - fn focus_handle(&self, cx: &AppContext) -> FocusHandle { + fn focus_handle(&self, _cx: &AppContext) -> FocusHandle { self.focus_handle.clone() } } @@ -9329,7 +9325,7 @@ impl Render for Editor { let background = match self.mode { EditorMode::SingleLine => cx.theme().system().transparent, - EditorMode::AutoHeight { max_lines } => cx.theme().system().transparent, + EditorMode::AutoHeight { max_lines: _ } => cx.theme().system().transparent, EditorMode::Full => cx.theme().colors().editor_background, }; @@ -9719,7 +9715,7 @@ impl InvalidationRegion for SnippetState { } } -pub fn diagnostic_block_renderer(diagnostic: Diagnostic, is_valid: bool) -> RenderBlock { +pub fn diagnostic_block_renderer(diagnostic: Diagnostic, _is_valid: bool) -> RenderBlock { let (text_without_backticks, code_ranges) = highlight_diagnostic_message(&diagnostic); Arc::new(move |cx: &mut BlockContext| { diff --git a/crates/editor2/src/editor_tests.rs b/crates/editor2/src/editor_tests.rs index 2548fc40a4afc2262a533536a6230c650183b1f0..563913bbe199e1402d175417f2356476e33376b2 100644 --- a/crates/editor2/src/editor_tests.rs +++ b/crates/editor2/src/editor_tests.rs @@ -12,7 +12,7 @@ use futures::StreamExt; use gpui::{ div, serde_json::{self, json}, - Div, Flatten, TestAppContext, VisualTestContext, WindowBounds, WindowOptions, + TestAppContext, VisualTestContext, WindowBounds, WindowOptions, }; use indoc::indoc; use language::{ @@ -77,7 +77,7 @@ fn test_edit_events(cx: &mut TestAppContext) { assert_eq!(mem::take(&mut *events.borrow_mut()), []); // Mutating editor 1 will emit an `Edited` event only for that editor. - editor1.update(cx, |editor, cx| editor.insert("X", cx)); + _ = editor1.update(cx, |editor, cx| editor.insert("X", cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -88,7 +88,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // Mutating editor 2 will emit an `Edited` event only for that editor. - editor2.update(cx, |editor, cx| editor.delete(&Delete, cx)); + _ = editor2.update(cx, |editor, cx| editor.delete(&Delete, cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -99,7 +99,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // Undoing on editor 1 will emit an `Edited` event only for that editor. - editor1.update(cx, |editor, cx| editor.undo(&Undo, cx)); + _ = editor1.update(cx, |editor, cx| editor.undo(&Undo, cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -110,7 +110,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // Redoing on editor 1 will emit an `Edited` event only for that editor. - editor1.update(cx, |editor, cx| editor.redo(&Redo, cx)); + _ = editor1.update(cx, |editor, cx| editor.redo(&Redo, cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -121,7 +121,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // Undoing on editor 2 will emit an `Edited` event only for that editor. - editor2.update(cx, |editor, cx| editor.undo(&Undo, cx)); + _ = editor2.update(cx, |editor, cx| editor.undo(&Undo, cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -132,7 +132,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // Redoing on editor 2 will emit an `Edited` event only for that editor. - editor2.update(cx, |editor, cx| editor.redo(&Redo, cx)); + _ = editor2.update(cx, |editor, cx| editor.redo(&Redo, cx)); assert_eq!( mem::take(&mut *events.borrow_mut()), [ @@ -143,7 +143,7 @@ fn test_edit_events(cx: &mut TestAppContext) { ); // No event is emitted when the mutation is a no-op. - editor2.update(cx, |editor, cx| { + _ = editor2.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([0..0])); editor.backspace(&Backspace, cx); @@ -161,7 +161,7 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) { let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let editor = cx.add_window(|cx| build_editor(buffer.clone(), cx)); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.start_transaction_at(now, cx); editor.change_selections(None, cx, |s| s.select_ranges([2..4])); @@ -181,7 +181,7 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) { editor.change_selections(None, cx, |s| s.select_ranges([2..2])); // Simulate an edit in another editor - buffer.update(cx, |buffer, cx| { + _ = buffer.update(cx, |buffer, cx| { buffer.start_transaction_at(now, cx); buffer.edit([(0..1, "a")], None, cx); buffer.edit([(1..1, "b")], None, cx); @@ -334,7 +334,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { build_editor(buffer, cx) }); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.begin_selection(DisplayPoint::new(2, 2), false, 1, cx); }); assert_eq!( @@ -344,7 +344,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { [DisplayPoint::new(2, 2)..DisplayPoint::new(2, 2)] ); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.update_selection( DisplayPoint::new(3, 3), 0, @@ -360,7 +360,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { [DisplayPoint::new(2, 2)..DisplayPoint::new(3, 3)] ); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.update_selection( DisplayPoint::new(1, 1), 0, @@ -376,7 +376,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { [DisplayPoint::new(2, 2)..DisplayPoint::new(1, 1)] ); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.end_selection(cx); view.update_selection( DisplayPoint::new(3, 3), @@ -393,7 +393,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { [DisplayPoint::new(2, 2)..DisplayPoint::new(1, 1)] ); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.begin_selection(DisplayPoint::new(3, 3), true, 1, cx); view.update_selection( DisplayPoint::new(0, 0), @@ -413,7 +413,7 @@ fn test_selection_with_mouse(cx: &mut TestAppContext) { ] ); - editor.update(cx, |view, cx| { + _ = editor.update(cx, |view, cx| { view.end_selection(cx); }); @@ -434,7 +434,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) { build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.begin_selection(DisplayPoint::new(2, 2), false, 1, cx); assert_eq!( view.selections.display_ranges(cx), @@ -442,7 +442,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.update_selection( DisplayPoint::new(3, 3), 0, @@ -455,7 +455,7 @@ fn test_canceling_pending_selection(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.cancel(&Cancel, cx); view.update_selection( DisplayPoint::new(1, 1), @@ -490,7 +490,7 @@ fn test_clone(cx: &mut TestAppContext) { build_editor(buffer, cx) }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges(selection_ranges.clone())); editor.fold_ranges( [ @@ -557,7 +557,7 @@ async fn test_navigation_history(cx: &mut TestAppContext) { .update(cx, |workspace, _| workspace.active_pane().clone()) .unwrap(); - workspace.update(cx, |v, cx| { + _ = workspace.update(cx, |_v, cx| { cx.build_view(|cx| { let buffer = MultiBuffer::build_simple(&sample_text(300, 5, 'a'), cx); let mut editor = build_editor(buffer.clone(), cx); @@ -671,7 +671,7 @@ fn test_cancel(cx: &mut TestAppContext) { build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.begin_selection(DisplayPoint::new(3, 4), false, 1, cx); view.update_selection( DisplayPoint::new(1, 1), @@ -698,7 +698,7 @@ fn test_cancel(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.cancel(&Cancel, cx); assert_eq!( view.selections.display_ranges(cx), @@ -706,7 +706,7 @@ fn test_cancel(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.cancel(&Cancel, cx); assert_eq!( view.selections.display_ranges(cx), @@ -744,7 +744,7 @@ fn test_fold_action(cx: &mut TestAppContext) { build_editor(buffer.clone(), cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([DisplayPoint::new(8, 0)..DisplayPoint::new(12, 0)]); }); @@ -812,7 +812,7 @@ fn test_move_cursor(cx: &mut TestAppContext) { let buffer = cx.update(|cx| MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx)); let view = cx.add_window(|cx| build_editor(buffer.clone(), cx)); - buffer.update(cx, |buffer, cx| { + _ = buffer.update(cx, |buffer, cx| { buffer.edit( vec![ (Point::new(1, 0)..Point::new(1, 0), "\t"), @@ -822,7 +822,7 @@ fn test_move_cursor(cx: &mut TestAppContext) { cx, ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { assert_eq!( view.selections.display_ranges(cx), &[DisplayPoint::new(0, 0)..DisplayPoint::new(0, 0)] @@ -893,7 +893,7 @@ fn test_move_cursor_multibyte(cx: &mut TestAppContext) { assert_eq!('ⓐ'.len_utf8(), 3); assert_eq!('α'.len_utf8(), 2); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.fold_ranges( vec![ Point::new(0, 6)..Point::new(0, 12), @@ -1006,7 +1006,7 @@ fn test_move_cursor_different_line_lengths(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", cx); build_editor(buffer.clone(), cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([empty_range(0, "ⓐⓑⓒⓓⓔ".len())]); }); @@ -1056,7 +1056,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\n def", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1), @@ -1065,7 +1065,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { }); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_to_beginning_of_line(&MoveToBeginningOfLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -1076,7 +1076,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_to_beginning_of_line(&MoveToBeginningOfLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -1087,7 +1087,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_to_beginning_of_line(&MoveToBeginningOfLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -1098,7 +1098,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_to_end_of_line(&MoveToEndOfLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -1110,7 +1110,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { }); // Moving to the end of line again is a no-op. - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_to_end_of_line(&MoveToEndOfLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -1121,7 +1121,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_left(&MoveLeft, cx); view.select_to_beginning_of_line( &SelectToBeginningOfLine { @@ -1138,7 +1138,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: true, @@ -1154,7 +1154,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_to_beginning_of_line( &SelectToBeginningOfLine { stop_at_soft_wraps: true, @@ -1170,7 +1170,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_to_end_of_line( &SelectToEndOfLine { stop_at_soft_wraps: true, @@ -1186,7 +1186,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.delete_to_end_of_line(&DeleteToEndOfLine, cx); assert_eq!(view.display_text(cx), "ab\n de"); assert_eq!( @@ -1198,7 +1198,7 @@ fn test_beginning_end_of_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.delete_to_beginning_of_line(&DeleteToBeginningOfLine, cx); assert_eq!(view.display_text(cx), "\n"); assert_eq!( @@ -1219,7 +1219,7 @@ fn test_prev_next_word_boundary(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("use std::str::{foo, bar}\n\n {baz.qux()}", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 11)..DisplayPoint::new(0, 11), @@ -1273,7 +1273,7 @@ fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut TestAppContext) { build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.set_wrap_width(Some(140.0.into()), cx); assert_eq!( view.display_text(cx), @@ -1714,7 +1714,7 @@ fn test_delete_to_word_boundary(cx: &mut TestAppContext) { build_editor(buffer.clone(), cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ // an empty selection - the preceding word fragment is deleted @@ -1727,7 +1727,7 @@ fn test_delete_to_word_boundary(cx: &mut TestAppContext) { assert_eq!(view.buffer.read(cx).read(cx).text(), "e two te four"); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ // an empty selection - the following word fragment is deleted @@ -1750,7 +1750,7 @@ fn test_newline(cx: &mut TestAppContext) { build_editor(buffer.clone(), cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 2)..DisplayPoint::new(0, 2), @@ -1793,7 +1793,7 @@ fn test_newline_with_old_selections(cx: &mut TestAppContext) { editor }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { // Edit the buffer directly, deleting ranges surrounding the editor's selections editor.buffer.update(cx, |buffer, cx| { buffer.edit( @@ -2003,7 +2003,7 @@ fn test_insert_with_old_selections(cx: &mut TestAppContext) { editor }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { // Edit the buffer directly, deleting ranges surrounding the editor's selections editor.buffer.update(cx, |buffer, cx| { buffer.edit([(2..5, ""), (10..13, ""), (18..21, "")], None, cx); @@ -2514,7 +2514,7 @@ fn test_delete_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 1)..DisplayPoint::new(0, 1), @@ -2537,7 +2537,7 @@ fn test_delete_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([DisplayPoint::new(2, 0)..DisplayPoint::new(0, 1)]) }); @@ -2946,7 +2946,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 0)..DisplayPoint::new(0, 1), @@ -2972,7 +2972,7 @@ fn test_duplicate_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 1)..DisplayPoint::new(1, 1), @@ -2999,7 +2999,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.fold_ranges( vec![ Point::new(0, 2)..Point::new(1, 2), @@ -3038,7 +3038,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_line_down(&MoveLineDown, cx); assert_eq!( view.display_text(cx), @@ -3055,7 +3055,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_line_down(&MoveLineDown, cx); assert_eq!( view.display_text(cx), @@ -3072,7 +3072,7 @@ fn test_move_line_up_down(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.move_line_up(&MoveLineUp, cx); assert_eq!( view.display_text(cx), @@ -3098,7 +3098,7 @@ fn test_move_line_up_down_with_blocks(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx); build_editor(buffer, cx) }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let snapshot = editor.buffer.read(cx).snapshot(cx); editor.insert_blocks( [BlockProperties { @@ -3420,7 +3420,7 @@ fn test_select_all(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple("abc\nde\nfgh", cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_all(&SelectAll, cx); assert_eq!( view.selections.display_ranges(cx), @@ -3437,7 +3437,7 @@ fn test_select_line(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple(&sample_text(6, 5, 'a'), cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 0)..DisplayPoint::new(0, 1), @@ -3456,7 +3456,7 @@ fn test_select_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_line(&SelectLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -3467,7 +3467,7 @@ fn test_select_line(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_line(&SelectLine, cx); assert_eq!( view.selections.display_ranges(cx), @@ -3484,7 +3484,7 @@ fn test_split_selection_into_lines(cx: &mut TestAppContext) { let buffer = MultiBuffer::build_simple(&sample_text(9, 5, 'a'), cx); build_editor(buffer, cx) }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.fold_ranges( vec![ Point::new(0, 2)..Point::new(1, 2), @@ -3505,7 +3505,7 @@ fn test_split_selection_into_lines(cx: &mut TestAppContext) { assert_eq!(view.display_text(cx), "aa⋯bbb\nccc⋯eeee\nfffff\nggggg\n⋯i"); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.split_selection_into_lines(&SplitSelectionIntoLines, cx); assert_eq!( view.display_text(cx), @@ -3522,7 +3522,7 @@ fn test_split_selection_into_lines(cx: &mut TestAppContext) { ); }); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([DisplayPoint::new(5, 0)..DisplayPoint::new(0, 1)]) }); @@ -3916,7 +3916,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { view.condition::(&cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) .await; - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 25)..DisplayPoint::new(0, 25), @@ -3935,7 +3935,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ] ); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx); }); assert_eq!( @@ -3946,7 +3946,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ] ); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx); }); assert_eq!( @@ -3955,7 +3955,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ); // Trying to expand the selected syntax node one more time has no effect. - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_larger_syntax_node(&SelectLargerSyntaxNode, cx); }); assert_eq!( @@ -3963,7 +3963,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { &[DisplayPoint::new(5, 0)..DisplayPoint::new(0, 0)] ); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx); }); assert_eq!( @@ -3974,7 +3974,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ] ); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx); }); assert_eq!( @@ -3986,7 +3986,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ] ); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx); }); assert_eq!( @@ -3999,7 +3999,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { ); // Trying to shrink the selected syntax node one more time has no effect. - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.select_smaller_syntax_node(&SelectSmallerSyntaxNode, cx); }); assert_eq!( @@ -4013,7 +4013,7 @@ async fn test_select_larger_smaller_syntax_node(cx: &mut gpui::TestAppContext) { // Ensure that we keep expanding the selection if the larger selection starts or ends within // a fold. - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.fold_ranges( vec![ Point::new(0, 21)..Point::new(0, 24), @@ -4082,7 +4082,7 @@ async fn test_autoindent_selections(cx: &mut gpui::TestAppContext) { .condition::(cx, |editor, cx| !editor.buffer.read(cx).is_parsing(cx)) .await; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([5..5, 8..8, 9..9])); editor.newline(&Newline, cx); assert_eq!(editor.text(cx), "fn a(\n \n) {\n \n}\n"); @@ -4646,7 +4646,7 @@ async fn test_surround_with_pair(cx: &mut gpui::TestAppContext) { view.condition::(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) .await; - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 0)..DisplayPoint::new(0, 1), @@ -4797,7 +4797,7 @@ async fn test_delete_autoclose_pair(cx: &mut gpui::TestAppContext) { .condition::(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) .await; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| { s.select_ranges([ Point::new(0, 1)..Point::new(0, 1), @@ -4883,9 +4883,9 @@ async fn test_snippets(cx: &mut gpui::TestAppContext) { ); let buffer = cx.update(|cx| MultiBuffer::build_simple(&text, cx)); - let (editor, mut cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); + let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let snippet = Snippet::parse("f(${1:one}, ${2:two}, ${1:three})$0").unwrap(); editor @@ -5003,7 +5003,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) { fs.insert_file("/file.rs", Default::default()).await; let project = Project::test(fs, ["/file.rs".as_ref()], cx).await; - project.update(cx, |project, _| project.languages().add(Arc::new(language))); + _ = project.update(cx, |project, _| project.languages().add(Arc::new(language))); let buffer = project .update(cx, |project, cx| project.open_local_buffer("/file.rs", cx)) .await @@ -5014,7 +5014,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) { let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); assert!(cx.read(|cx| editor.is_dirty(cx))); let save = editor @@ -5035,7 +5035,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) { .next() .await; cx.executor().start_waiting(); - let x = save.await; + let _x = save.await; assert_eq!( editor.update(cx, |editor, cx| editor.text(cx)), @@ -5043,7 +5043,7 @@ async fn test_document_format_during_save(cx: &mut gpui::TestAppContext) { ); assert!(!cx.read(|cx| editor.is_dirty(cx))); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); assert!(cx.read(|cx| editor.is_dirty(cx))); // Ensure we can still save even if formatting hangs. @@ -5122,7 +5122,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) { fs.insert_file("/file.rs", Default::default()).await; let project = Project::test(fs, ["/file.rs".as_ref()], cx).await; - project.update(cx, |project, _| project.languages().add(Arc::new(language))); + _ = project.update(cx, |project, _| project.languages().add(Arc::new(language))); let buffer = project .update(cx, |project, cx| project.open_local_buffer("/file.rs", cx)) .await @@ -5133,7 +5133,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) { let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); assert!(cx.read(|cx| editor.is_dirty(cx))); let save = editor @@ -5161,7 +5161,7 @@ async fn test_range_format_during_save(cx: &mut gpui::TestAppContext) { ); assert!(!cx.read(|cx| editor.is_dirty(cx))); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); assert!(cx.read(|cx| editor.is_dirty(cx))); // Ensure we can still save even if formatting hangs. @@ -5247,7 +5247,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) { fs.insert_file("/file.rs", Default::default()).await; let project = Project::test(fs, ["/file.rs".as_ref()], cx).await; - project.update(cx, |project, _| { + _ = project.update(cx, |project, _| { project.languages().add(Arc::new(language)); }); let buffer = project @@ -5260,7 +5260,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) { let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); let format = editor .update(cx, |editor, cx| { @@ -5288,7 +5288,7 @@ async fn test_document_format_manual_trigger(cx: &mut gpui::TestAppContext) { "one, two\nthree\n" ); - editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); + _ = editor.update(cx, |editor, cx| editor.set_text("one\ntwo\nthree\n", cx)); // Ensure we don't lock if formatting hangs. fake_server.handle_request::(move |params, _| async move { assert_eq!( @@ -5627,7 +5627,7 @@ async fn test_completion(cx: &mut gpui::TestAppContext) { handle_resolve_completion_request(&mut cx, None).await; apply_additional_edits.await.unwrap(); - cx.update(|cx| { + _ = cx.update(|cx| { cx.update_global::(|settings, cx| { settings.update_user_settings::(cx, |settings| { settings.show_completions_on_input = Some(false); @@ -6046,7 +6046,7 @@ fn test_editing_disjoint_excerpts(cx: &mut TestAppContext) { }); let (view, cx) = cx.add_window_view(|cx| build_editor(multibuffer, cx)); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { assert_eq!(view.text(cx), "aaaa\nbbbb"); view.change_selections(None, cx, |s| { s.select_ranges([ @@ -6116,7 +6116,7 @@ fn test_editing_overlapping_excerpts(cx: &mut TestAppContext) { }); let (view, cx) = cx.add_window_view(|cx| build_editor(multibuffer, cx)); - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { let (expected_text, selection_ranges) = marked_text_ranges( indoc! {" aaaa @@ -6210,7 +6210,7 @@ fn test_refresh_selections(cx: &mut TestAppContext) { }); // Refreshing selections is a no-op when excerpts haven't changed. - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.refresh()); assert_eq!( editor.selections.ranges(cx), @@ -6221,10 +6221,10 @@ fn test_refresh_selections(cx: &mut TestAppContext) { ); }); - multibuffer.update(cx, |multibuffer, cx| { + _ = multibuffer.update(cx, |multibuffer, cx| { multibuffer.remove_excerpts([excerpt1_id.unwrap()], cx); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { // Removing an excerpt causes the first selection to become degenerate. assert_eq!( editor.selections.ranges(cx), @@ -6289,10 +6289,10 @@ fn test_refresh_selections_while_selecting_with_mouse(cx: &mut TestAppContext) { editor }); - multibuffer.update(cx, |multibuffer, cx| { + _ = multibuffer.update(cx, |multibuffer, cx| { multibuffer.remove_excerpts([excerpt1_id.unwrap()], cx); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( editor.selections.ranges(cx), [Point::new(0, 0)..Point::new(0, 0)] @@ -6356,7 +6356,7 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) { view.condition::(cx, |view, cx| !view.buffer.read(cx).is_parsing(cx)) .await; - view.update(cx, |view, cx| { + _ = view.update(cx, |view, cx| { view.change_selections(None, cx, |s| { s.select_display_ranges([ DisplayPoint::new(0, 2)..DisplayPoint::new(0, 3), @@ -6393,7 +6393,7 @@ fn test_highlighted_ranges(cx: &mut TestAppContext) { build_editor(buffer.clone(), cx) }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { struct Type1; struct Type2; @@ -6498,7 +6498,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) { let is_still_following = Rc::new(RefCell::new(true)); let follower_edit_event_count = Rc::new(RefCell::new(0)); let pending_update = Rc::new(RefCell::new(None)); - follower.update(cx, { + _ = follower.update(cx, { let update = pending_update.clone(); let is_still_following = is_still_following.clone(); let follower_edit_event_count = follower_edit_event_count.clone(); @@ -6515,7 +6515,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) { cx.subscribe( &follower.root_view(cx).unwrap(), - move |_, _, event: &EditorEvent, cx| { + move |_, _, event: &EditorEvent, _cx| { if matches!(Editor::to_follow_event(event), Some(FollowEvent::Unfollow)) { *is_still_following.borrow_mut() = false; } @@ -6530,7 +6530,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) { }); // Update the selections only - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.change_selections(None, cx, |s| s.select_ranges([1..1])); }); follower @@ -6540,14 +6540,14 @@ async fn test_following(cx: &mut gpui::TestAppContext) { .unwrap() .await .unwrap(); - follower.update(cx, |follower, cx| { + _ = follower.update(cx, |follower, cx| { assert_eq!(follower.selections.ranges(cx), vec![1..1]); }); assert_eq!(*is_still_following.borrow(), true); assert_eq!(*follower_edit_event_count.borrow(), 0); // Update the scroll position only - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.set_scroll_position(gpui::Point::new(1.5, 3.5), cx); }); follower @@ -6568,7 +6568,7 @@ async fn test_following(cx: &mut gpui::TestAppContext) { // Update the selections and scroll position. The follower's scroll position is updated // via autoscroll, not via the leader's exact scroll position. - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.change_selections(None, cx, |s| s.select_ranges([0..0])); leader.request_autoscroll(Autoscroll::newest(), cx); leader.set_scroll_position(gpui::Point::new(1.5, 3.5), cx); @@ -6580,14 +6580,14 @@ async fn test_following(cx: &mut gpui::TestAppContext) { .unwrap() .await .unwrap(); - follower.update(cx, |follower, cx| { + _ = follower.update(cx, |follower, cx| { assert_eq!(follower.scroll_position(cx), gpui::Point::new(1.5, 0.0)); assert_eq!(follower.selections.ranges(cx), vec![0..0]); }); assert_eq!(*is_still_following.borrow(), true); // Creating a pending selection that precedes another selection - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.change_selections(None, cx, |s| s.select_ranges([1..1])); leader.begin_selection(DisplayPoint::new(0, 0), true, 1, cx); }); @@ -6598,13 +6598,13 @@ async fn test_following(cx: &mut gpui::TestAppContext) { .unwrap() .await .unwrap(); - follower.update(cx, |follower, cx| { + _ = follower.update(cx, |follower, cx| { assert_eq!(follower.selections.ranges(cx), vec![0..0, 1..1]); }); assert_eq!(*is_still_following.borrow(), true); // Extend the pending selection so that it surrounds another selection - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.extend_selection(DisplayPoint::new(0, 2), 1, cx); }); follower @@ -6614,12 +6614,12 @@ async fn test_following(cx: &mut gpui::TestAppContext) { .unwrap() .await .unwrap(); - follower.update(cx, |follower, cx| { + _ = follower.update(cx, |follower, cx| { assert_eq!(follower.selections.ranges(cx), vec![0..2]); }); // Scrolling locally breaks the follow - follower.update(cx, |follower, cx| { + _ = follower.update(cx, |follower, cx| { let top_anchor = follower.buffer().read(cx).read(cx).anchor_after(0); follower.set_scroll_anchor( ScrollAnchor { @@ -6695,7 +6695,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) { }); // Insert some excerpts. - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.buffer.update(cx, |multibuffer, cx| { let excerpt_ids = multibuffer.push_excerpts( buffer_1.clone(), @@ -6771,7 +6771,7 @@ async fn test_following_with_multiple_excerpts(cx: &mut gpui::TestAppContext) { ); // Remove some excerpts. - leader.update(cx, |leader, cx| { + _ = leader.update(cx, |leader, cx| { leader.buffer.update(cx, |multibuffer, cx| { let excerpt_ids = multibuffer.excerpt_ids(); multibuffer.remove_excerpts([excerpt_ids[1], excerpt_ids[2]], cx); @@ -6814,8 +6814,8 @@ async fn go_to_prev_overlapping_diagnostic( } "}); - cx.update(|cx| { - project.update(cx, |project, cx| { + _ = cx.update(|cx| { + _ = project.update(cx, |project, cx| { project .update_diagnostics( LanguageServerId(0), @@ -7113,7 +7113,7 @@ async fn test_copilot(executor: BackgroundExecutor, cx: &mut gpui::TestAppContex init_test(cx, |_| {}); let (copilot, copilot_lsp) = Copilot::fake(cx); - cx.update(|cx| cx.set_global(copilot)); + _ = cx.update(|cx| cx.set_global(copilot)); let mut cx = EditorLspTestContext::new_rust( lsp::ServerCapabilities { completion_provider: Some(lsp::CompletionOptions { @@ -7366,7 +7366,7 @@ async fn test_copilot_completion_invalidation( init_test(cx, |_| {}); let (copilot, copilot_lsp) = Copilot::fake(cx); - cx.update(|cx| cx.set_global(copilot)); + _ = cx.update(|cx| cx.set_global(copilot)); let mut cx = EditorLspTestContext::new_rust( lsp::ServerCapabilities { completion_provider: Some(lsp::CompletionOptions { @@ -7430,7 +7430,7 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T init_test(cx, |_| {}); let (copilot, copilot_lsp) = Copilot::fake(cx); - cx.update(|cx| cx.set_global(copilot)); + _ = cx.update(|cx| cx.set_global(copilot)); let buffer_1 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "a = 1\nb = 2\n")); let buffer_2 = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), "c = 3\nd = 4\n")); @@ -7465,7 +7465,7 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T }], vec![], ); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { // Ensure copilot suggestions are shown for the first excerpt. editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(1, 5)..Point::new(1, 5)]) @@ -7473,7 +7473,7 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T editor.next_copilot_suggestion(&Default::default(), cx); }); executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert!(editor.has_active_copilot_suggestion(cx)); assert_eq!( editor.display_text(cx), @@ -7491,7 +7491,7 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T }], vec![], ); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { // Move to another excerpt, ensuring the suggestion gets cleared. editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(4, 5)..Point::new(4, 5)]) @@ -7515,7 +7515,7 @@ async fn test_copilot_multibuffer(executor: BackgroundExecutor, cx: &mut gpui::T // Ensure the new suggestion is displayed when the debounce timeout expires. executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert!(editor.has_active_copilot_suggestion(cx)); assert_eq!( editor.display_text(cx), @@ -7535,7 +7535,7 @@ async fn test_copilot_disabled_globs(executor: BackgroundExecutor, cx: &mut gpui }); let (copilot, copilot_lsp) = Copilot::fake(cx); - cx.update(|cx| cx.set_global(copilot)); + _ = cx.update(|cx| cx.set_global(copilot)); let fs = FakeFs::new(cx.executor()); fs.insert_tree( @@ -7594,7 +7594,7 @@ async fn test_copilot_disabled_globs(executor: BackgroundExecutor, cx: &mut gpui }) }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |selections| { selections.select_ranges([Point::new(0, 0)..Point::new(0, 0)]) }); @@ -7604,7 +7604,7 @@ async fn test_copilot_disabled_globs(executor: BackgroundExecutor, cx: &mut gpui executor.advance_clock(COPILOT_DEBOUNCE_TIMEOUT); assert!(copilot_requests.try_next().is_err()); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(2, 0)..Point::new(2, 0)]) }); @@ -7659,7 +7659,7 @@ async fn test_on_type_formatting_not_triggered(cx: &mut gpui::TestAppContext) { ) .await; let project = Project::test(fs, ["/a".as_ref()], cx).await; - project.update(cx, |project, _| project.languages().add(Arc::new(language))); + _ = project.update(cx, |project, _| project.languages().add(Arc::new(language))); let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx)); let cx = &mut VisualTestContext::from_window(*workspace, cx); @@ -7717,7 +7717,7 @@ async fn test_on_type_formatting_not_triggered(cx: &mut gpui::TestAppContext) { cx.executor().run_until_parked(); - buffer.update(cx, |buffer, _| { + _ = buffer.update(cx, |buffer, _| { assert_eq!( buffer.text(), "fn main() { let a = {5}; }", @@ -7770,7 +7770,7 @@ async fn test_language_server_restart_due_to_settings_change(cx: &mut gpui::Test ) .await; let project = Project::test(fs, ["/a".as_ref()], cx).await; - project.update(cx, |project, _| project.languages().add(Arc::new(language))); + _ = project.update(cx, |project, _| project.languages().add(Arc::new(language))); let _window = cx.add_window(|cx| Workspace::test_new(project.clone(), cx)); let _buffer = project .update(cx, |project, cx| { @@ -8082,7 +8082,7 @@ async fn test_document_format_with_prettier(cx: &mut gpui::TestAppContext) { let project = Project::test(fs, ["/file.rs".as_ref()], cx).await; let prettier_format_suffix = project::TEST_PRETTIER_FORMAT_SUFFIX; - project.update(cx, |project, _| { + _ = project.update(cx, |project, _| { project.languages().add(Arc::new(language)); }); let buffer = project @@ -8093,7 +8093,7 @@ async fn test_document_format_with_prettier(cx: &mut gpui::TestAppContext) { let buffer_text = "one\ntwo\nthree\n"; let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx)); let (editor, cx) = cx.add_window_view(|cx| build_editor(buffer, cx)); - editor.update(cx, |editor, cx| editor.set_text(buffer_text, cx)); + _ = editor.update(cx, |editor, cx| editor.set_text(buffer_text, cx)); editor .update(cx, |editor, cx| { @@ -8244,7 +8244,7 @@ pub(crate) fn update_test_language_settings( cx: &mut TestAppContext, f: impl Fn(&mut AllLanguageSettingsContent), ) { - cx.update(|cx| { + _ = cx.update(|cx| { cx.update_global(|store: &mut SettingsStore, cx| { store.update_user_settings::(cx, f); }); @@ -8255,7 +8255,7 @@ pub(crate) fn update_test_project_settings( cx: &mut TestAppContext, f: impl Fn(&mut ProjectSettings), ) { - cx.update(|cx| { + _ = cx.update(|cx| { cx.update_global(|store: &mut SettingsStore, cx| { store.update_user_settings::(cx, f); }); @@ -8263,7 +8263,7 @@ pub(crate) fn update_test_project_settings( } pub(crate) fn init_test(cx: &mut TestAppContext, f: fn(&mut AllLanguageSettingsContent)) { - cx.update(|cx| { + _ = cx.update(|cx| { let store = SettingsStore::test(cx); cx.set_global(store); theme::init(theme::LoadThemes::JustBase, cx); diff --git a/crates/editor2/src/element.rs b/crates/editor2/src/element.rs index 568adce5566c4456366dd5ad4b6682f4a4905037..eb9f4106ea43d57e5339511ad52b8255c6e35882 100644 --- a/crates/editor2/src/element.rs +++ b/crates/editor2/src/element.rs @@ -16,24 +16,23 @@ use crate::{ mouse_context_menu, scroll::scroll_amount::ScrollAmount, CursorShape, DisplayPoint, Editor, EditorMode, EditorSettings, EditorSnapshot, EditorStyle, - HalfPageDown, HalfPageUp, LineDown, LineUp, MoveDown, OpenExcerpts, PageDown, PageUp, Point, - SelectPhase, Selection, SoftWrap, ToPoint, MAX_LINE_LEN, + HalfPageDown, HalfPageUp, LineDown, LineUp, OpenExcerpts, PageDown, PageUp, Point, SelectPhase, + Selection, SoftWrap, ToPoint, MAX_LINE_LEN, }; use anyhow::Result; use collections::{BTreeMap, HashMap}; use git::diff::DiffHunkStatus; use gpui::{ div, fill, outline, overlay, point, px, quad, relative, size, transparent_black, Action, - AnchorCorner, AnyElement, AsyncWindowContext, AvailableSpace, BorrowWindow, Bounds, - ContentMask, Corners, CursorStyle, DispatchPhase, Edges, Element, ElementId, - ElementInputHandler, Entity, EntityId, Hsla, InteractiveBounds, InteractiveElement, - IntoElement, LineLayout, ModifiersChangedEvent, MouseButton, MouseDownEvent, MouseMoveEvent, - MouseUpEvent, ParentElement, Pixels, RenderOnce, ScrollWheelEvent, ShapedLine, SharedString, - Size, StackingOrder, StatefulInteractiveElement, Style, Styled, TextRun, TextStyle, View, - ViewContext, WeakView, WindowContext, WrappedLine, + AnchorCorner, AnyElement, AvailableSpace, BorrowWindow, Bounds, ContentMask, Corners, + CursorStyle, DispatchPhase, Edges, Element, ElementInputHandler, Hsla, InteractiveBounds, + InteractiveElement, IntoElement, ModifiersChangedEvent, MouseButton, MouseDownEvent, + MouseMoveEvent, MouseUpEvent, ParentElement, Pixels, ScrollWheelEvent, ShapedLine, + SharedString, Size, StackingOrder, StatefulInteractiveElement, Style, Styled, TextRun, + TextStyle, View, ViewContext, WindowContext, }; use itertools::Itertools; -use language::{language_settings::ShowWhitespaceSetting, Language}; +use language::language_settings::ShowWhitespaceSetting; use multi_buffer::Anchor; use project::{ project_settings::{GitGutterSetting, ProjectSettings}, @@ -52,15 +51,11 @@ use std::{ }; use sum_tree::Bias; use theme::{ActiveTheme, PlayerColor}; -use ui::{ - h_stack, ButtonLike, ButtonStyle, Disclosure, IconButton, IconElement, IconSize, Label, Tooltip, -}; -use ui::{prelude::*, Icon}; +use ui::prelude::*; +use ui::{h_stack, ButtonLike, ButtonStyle, IconButton, Label, Tooltip}; use util::ResultExt; use workspace::item::Item; -enum FoldMarkers {} - struct SelectionLayout { head: DisplayPoint, cursor_shape: CursorShape, @@ -732,7 +727,7 @@ impl EditorElement { ix as f32 * line_height - (scroll_top % line_height), ); - line.paint(line_origin, line_height, cx); + line.paint(line_origin, line_height, cx).log_err(); } } @@ -2687,11 +2682,13 @@ impl LineWithInvisibles { let line_height = layout.position_map.line_height; let line_y = line_height * row as f32 - layout.position_map.scroll_position.y; - self.line.paint( - content_origin + gpui::point(-layout.position_map.scroll_position.x, line_y), - line_height, - cx, - ); + self.line + .paint( + content_origin + gpui::point(-layout.position_map.scroll_position.x, line_y), + line_height, + cx, + ) + .log_err(); self.draw_invisibles( &selection_ranges, @@ -2746,7 +2743,7 @@ impl LineWithInvisibles { continue; } } - invisible_symbol.paint(origin, line_height, cx); + invisible_symbol.paint(origin, line_height, cx).log_err(); } } } @@ -3090,7 +3087,9 @@ impl Cursor { cx.paint_quad(cursor); if let Some(block_text) = &self.block_text { - block_text.paint(self.origin + origin, self.line_height, cx); + block_text + .paint(self.origin + origin, self.line_height, cx) + .log_err(); } } @@ -3251,7 +3250,7 @@ mod tests { editor_tests::{init_test, update_test_language_settings}, Editor, MultiBuffer, }; - use gpui::{EmptyView, TestAppContext}; + use gpui::TestAppContext; use language::language_settings; use log::info; use std::{num::NonZeroU32, sync::Arc}; @@ -3432,7 +3431,7 @@ mod tests { let editor = window.root(cx).unwrap(); let style = cx.update(|cx| editor.read(cx).style().unwrap().clone()); let mut element = EditorElement::new(&editor, style); - let state = window.update(cx, |editor, cx| { + let _state = window.update(cx, |editor, cx| { editor.cursor_shape = CursorShape::Block; editor.change_selections(None, cx, |s| { s.select_display_ranges([ @@ -3504,7 +3503,7 @@ mod tests { .unwrap(); let mut element = EditorElement::new(&editor, style); - let mut state = cx + let state = cx .update_window(window.into(), |_, cx| { element.compute_layout( Bounds { @@ -3768,17 +3767,15 @@ fn compute_auto_height_layout( .width; let mut snapshot = editor.snapshot(cx); - let gutter_padding; let gutter_width; let gutter_margin; if snapshot.show_gutter { let descent = cx.text_system().descent(font_id, font_size); let gutter_padding_factor = 3.5; - gutter_padding = (em_width * gutter_padding_factor).round(); + let gutter_padding = (em_width * gutter_padding_factor).round(); gutter_width = max_line_number_width + gutter_padding * 2.0; gutter_margin = -descent; } else { - gutter_padding = Pixels::ZERO; gutter_width = Pixels::ZERO; gutter_margin = Pixels::ZERO; }; diff --git a/crates/editor2/src/hover_popover.rs b/crates/editor2/src/hover_popover.rs index 3a53a1bd1d6cca3e48dc3267b65b1d8d9527ac4f..ca2fc4e9b2a2aa054703bb271d1f8af18bd151b3 100644 --- a/crates/editor2/src/hover_popover.rs +++ b/crates/editor2/src/hover_popover.rs @@ -6,12 +6,12 @@ use crate::{ }; use futures::FutureExt; use gpui::{ - actions, div, px, AnyElement, AppContext, CursorStyle, InteractiveElement, IntoElement, Model, - MouseButton, ParentElement, Pixels, SharedString, Size, StatefulInteractiveElement, Styled, - Task, ViewContext, WeakView, + actions, div, px, AnyElement, CursorStyle, InteractiveElement, IntoElement, Model, MouseButton, + ParentElement, Pixels, SharedString, Size, StatefulInteractiveElement, Styled, Task, + ViewContext, WeakView, }; use language::{markdown, Bias, DiagnosticEntry, Language, LanguageRegistry, ParsedMarkdown}; -use lsp::DiagnosticSeverity; + use project::{HoverBlock, HoverBlockKind, InlayHintLabelPart, Project}; use settings::Settings; use std::{ops::Range, sync::Arc, time::Duration}; @@ -869,7 +869,7 @@ mod tests { let editor = cx.add_window(|cx| Editor::single_line(cx)); editor - .update(cx, |editor, cx| { + .update(cx, |editor, _cx| { let style = editor.style.clone().unwrap(); struct Row { diff --git a/crates/editor2/src/inlay_hint_cache.rs b/crates/editor2/src/inlay_hint_cache.rs index aab985ff9030988481796b0a4181189662f749c9..aac9e54cf3bf1906e3fc277d03ea5c40eb4abfac 100644 --- a/crates/editor2/src/inlay_hint_cache.rs +++ b/crates/editor2/src/inlay_hint_cache.rs @@ -1203,7 +1203,7 @@ pub mod tests { ExcerptRange, }; use futures::StreamExt; - use gpui::{Context, TestAppContext, View, WindowHandle}; + use gpui::{Context, TestAppContext, WindowHandle}; use itertools::Itertools; use language::{ language_settings::AllLanguageSettingsContent, FakeLspAdapter, Language, LanguageConfig, @@ -1214,7 +1214,6 @@ pub mod tests { use serde_json::json; use settings::SettingsStore; use text::{Point, ToPoint}; - use workspace::Workspace; use crate::editor_tests::update_test_language_settings; @@ -1273,7 +1272,7 @@ pub mod tests { cx.executor().run_until_parked(); let mut edits_made = 1; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1292,13 +1291,13 @@ pub mod tests { ); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([13..13])); editor.handle_input("some change", cx); edits_made += 1; }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string(), "1".to_string()]; assert_eq!( expected_hints, @@ -1323,7 +1322,7 @@ pub mod tests { .expect("inlay refresh request failed"); edits_made += 1; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string(), "1".to_string(), "2".to_string()]; assert_eq!( expected_hints, @@ -1383,7 +1382,7 @@ pub mod tests { cx.executor().run_until_parked(); let mut edits_made = 1; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1414,7 +1413,7 @@ pub mod tests { }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1438,7 +1437,7 @@ pub mod tests { cx.executor().run_until_parked(); edits_made += 1; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!( expected_hints, @@ -1543,7 +1542,7 @@ pub mod tests { .next() .await; cx.executor().run_until_parked(); - rs_editor.update(cx, |editor, cx| { + _ = rs_editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1594,7 +1593,7 @@ pub mod tests { .next() .await; cx.executor().run_until_parked(); - md_editor.update(cx, |editor, cx| { + _ = md_editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1605,12 +1604,12 @@ pub mod tests { assert_eq!(editor.inlay_hint_cache().version, 1); }); - rs_editor.update(cx, |editor, cx| { + _ = rs_editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([13..13])); editor.handle_input("some rs change", cx); }); cx.executor().run_until_parked(); - rs_editor.update(cx, |editor, cx| { + _ = rs_editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!( expected_hints, @@ -1624,7 +1623,7 @@ pub mod tests { "Every time hint cache changes, cache version should be incremented" ); }); - md_editor.update(cx, |editor, cx| { + _ = md_editor.update(cx, |editor, cx| { let expected_hints = vec!["0".to_string()]; assert_eq!( expected_hints, @@ -1635,12 +1634,12 @@ pub mod tests { assert_eq!(editor.inlay_hint_cache().version, 1); }); - md_editor.update(cx, |editor, cx| { + _ = md_editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([13..13])); editor.handle_input("some md change", cx); }); cx.executor().run_until_parked(); - md_editor.update(cx, |editor, cx| { + _ = md_editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!( expected_hints, @@ -1650,7 +1649,7 @@ pub mod tests { assert_eq!(expected_hints, visible_hint_labels(editor, cx)); assert_eq!(editor.inlay_hint_cache().version, 2); }); - rs_editor.update(cx, |editor, cx| { + _ = rs_editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!( expected_hints, @@ -1725,7 +1724,7 @@ pub mod tests { cx.executor().run_until_parked(); let mut edits_made = 1; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 1, @@ -1760,7 +1759,7 @@ pub mod tests { .await .expect("inlay refresh request failed"); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 2, @@ -1832,7 +1831,7 @@ pub mod tests { }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 2, @@ -1876,7 +1875,7 @@ pub mod tests { }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 2, @@ -1906,7 +1905,7 @@ pub mod tests { .await .expect("inlay refresh request failed"); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 2, @@ -1932,7 +1931,7 @@ pub mod tests { }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 3, @@ -1968,7 +1967,7 @@ pub mod tests { .await .expect("inlay refresh request failed"); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( lsp_request_count.load(Ordering::Relaxed), 4, @@ -2035,7 +2034,7 @@ pub mod tests { "initial change #2", "initial change #3", ] { - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([13..13])); editor.handle_input(change_after_opening, cx); }); @@ -2044,7 +2043,7 @@ pub mod tests { cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let current_text = editor.text(cx); for change in &expected_changes { assert!( @@ -2079,7 +2078,7 @@ pub mod tests { expected_changes.push(async_later_change); let task_editor = editor.clone(); edits.push(cx.spawn(|mut cx| async move { - task_editor.update(&mut cx, |editor, cx| { + _ = task_editor.update(&mut cx, |editor, cx| { editor.change_selections(None, cx, |s| s.select_ranges([13..13])); editor.handle_input(async_later_change, cx); }); @@ -2088,7 +2087,7 @@ pub mod tests { let _ = future::join_all(edits).await; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let current_text = editor.text(cx); for change in &expected_changes { assert!( @@ -2246,7 +2245,7 @@ pub mod tests { lsp::Position::new(initial_visible_range.end.row * 2, 2); let mut expected_invisible_query_start = lsp_initial_visible_range.end; expected_invisible_query_start.character += 1; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let ranges = lsp_request_ranges.lock().drain(..).collect::>(); assert_eq!(ranges.len(), 2, "When scroll is at the edge of a big document, its visible part and the same range further should be queried in order, but got: {ranges:?}"); @@ -2273,7 +2272,7 @@ pub mod tests { ); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.scroll_screen(&ScrollAmount::Page(1.0), cx); editor.scroll_screen(&ScrollAmount::Page(1.0), cx); }); @@ -2343,7 +2342,7 @@ pub mod tests { }) .unwrap(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::center()), cx, |s| { s.select_ranges([selection_in_cached_range..selection_in_cached_range]) }); @@ -2352,7 +2351,7 @@ pub mod tests { INVISIBLE_RANGES_HINTS_REQUEST_DELAY_MILLIS + 100, )); cx.executor().run_until_parked(); - editor.update(cx, |_, _| { + _ = editor.update(cx, |_, _| { let ranges = lsp_request_ranges .lock() .drain(..) @@ -2362,14 +2361,14 @@ pub mod tests { assert_eq!(lsp_request_count.load(Ordering::Acquire), 4); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.handle_input("++++more text++++", cx); }); cx.executor().advance_clock(Duration::from_millis( INVISIBLE_RANGES_HINTS_REQUEST_DELAY_MILLIS + 100, )); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let mut ranges = lsp_request_ranges.lock().drain(..).collect::>(); ranges.sort_by_key(|r| r.start); @@ -2597,7 +2596,7 @@ pub mod tests { .await; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec![ "main hint #0".to_string(), "main hint #1".to_string(), @@ -2615,7 +2614,7 @@ pub mod tests { assert_eq!(editor.inlay_hint_cache().version, expected_hints.len(), "Every visible excerpt hints should bump the verison"); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::Next), cx, |s| { s.select_ranges([Point::new(4, 0)..Point::new(4, 0)]) }); @@ -2627,7 +2626,7 @@ pub mod tests { }); }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec![ "main hint #0".to_string(), "main hint #1".to_string(), @@ -2646,7 +2645,7 @@ pub mod tests { "Due to every excerpt having one hint, we update cache per new excerpt scrolled"); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::Next), cx, |s| { s.select_ranges([Point::new(100, 0)..Point::new(100, 0)]) }); @@ -2677,13 +2676,13 @@ pub mod tests { expected_hints.len() }).unwrap(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(Some(Autoscroll::Next), cx, |s| { s.select_ranges([Point::new(4, 0)..Point::new(4, 0)]) }); }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec![ "main hint #0".to_string(), "main hint #1".to_string(), @@ -2705,7 +2704,7 @@ pub mod tests { }); editor_edited.store(true, Ordering::Release); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| { // TODO if this gets set to hint boundary (e.g. 56) we sometimes get an extra cache version bump, why? s.select_ranges([Point::new(57, 0)..Point::new(57, 0)]) @@ -2713,7 +2712,7 @@ pub mod tests { editor.handle_input("++++more text++++", cx); }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec![ "main hint(edited) #0".to_string(), "main hint(edited) #1".to_string(), @@ -2895,7 +2894,7 @@ pub mod tests { .await; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( vec!["main hint #0".to_string(), "other hint #0".to_string()], cached_hint_labels(editor), @@ -2912,13 +2911,13 @@ pub mod tests { ); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.buffer().update(cx, |multibuffer, cx| { multibuffer.remove_excerpts(buffer_2_excerpts, cx) }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert_eq!( vec!["main hint #0".to_string()], cached_hint_labels(editor), @@ -2944,7 +2943,7 @@ pub mod tests { }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["main hint #0".to_string()]; assert_eq!( expected_hints, @@ -3041,13 +3040,13 @@ pub mod tests { .await; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.change_selections(None, cx, |s| { s.select_ranges([Point::new(10, 0)..Point::new(10, 0)]) }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!(expected_hints, cached_hint_labels(editor)); assert_eq!(expected_hints, visible_hint_labels(editor, cx)); @@ -3068,7 +3067,7 @@ pub mod tests { let (file_with_hints, editor, fake_server) = prepare_test_objects(cx).await; - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx) }); cx.executor().start_waiting(); @@ -3099,7 +3098,7 @@ pub mod tests { .next() .await; cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["1".to_string()]; assert_eq!( expected_hints, @@ -3114,11 +3113,11 @@ pub mod tests { ); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert!( cached_hint_labels(editor).is_empty(), "Should clear hints after 2nd toggle" @@ -3136,7 +3135,7 @@ pub mod tests { }) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["2".to_string()]; assert_eq!( expected_hints, @@ -3147,11 +3146,11 @@ pub mod tests { assert_eq!(editor.inlay_hint_cache().version, 3); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert!( cached_hint_labels(editor).is_empty(), "Should clear hints after enabling in settings and a 3rd toggle" @@ -3160,11 +3159,11 @@ pub mod tests { assert_eq!(editor.inlay_hint_cache().version, 4); }); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { editor.toggle_inlay_hints(&crate::ToggleInlayHints, cx) }); cx.executor().run_until_parked(); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { let expected_hints = vec!["3".to_string()]; assert_eq!( expected_hints, @@ -3223,7 +3222,7 @@ pub mod tests { .await; let project = Project::test(fs, ["/a".as_ref()], cx).await; - project.update(cx, |project, _| project.languages().add(Arc::new(language))); + _ = project.update(cx, |project, _| project.languages().add(Arc::new(language))); let buffer = project .update(cx, |project, cx| { project.open_local_buffer("/a/main.rs", cx) @@ -3235,7 +3234,7 @@ pub mod tests { let fake_server = fake_servers.next().await.unwrap(); let editor = cx.add_window(|cx| Editor::for_buffer(buffer, Some(project), cx)); - editor.update(cx, |editor, cx| { + _ = editor.update(cx, |editor, cx| { assert!(cached_hint_labels(editor).is_empty()); assert!(visible_hint_labels(editor, cx).is_empty()); assert_eq!(editor.inlay_hint_cache().version, 0); diff --git a/crates/editor2/src/items.rs b/crates/editor2/src/items.rs index ddb5b25db2fd990a675b15165b8d7d19282e3b1d..b10b891d0dbf1e3aa77e8c2a36d0a87add9a53d6 100644 --- a/crates/editor2/src/items.rs +++ b/crates/editor2/src/items.rs @@ -1,17 +1,15 @@ use crate::{ editor_settings::SeedQuerySetting, link_go_to_definition::hide_link_definition, - movement::surrounding_word, persistence::DB, scroll::ScrollAnchor, Anchor, Autoscroll, Editor, - EditorEvent, EditorSettings, ExcerptId, ExcerptRange, MultiBuffer, MultiBufferSnapshot, - NavigationData, ToPoint as _, + persistence::DB, scroll::ScrollAnchor, Anchor, Autoscroll, Editor, EditorEvent, EditorSettings, + ExcerptId, ExcerptRange, MultiBuffer, MultiBufferSnapshot, NavigationData, ToPoint as _, }; use anyhow::{anyhow, Context as _, Result}; use collections::HashSet; use futures::future::try_join_all; use gpui::{ - div, point, AnyElement, AppContext, AsyncAppContext, AsyncWindowContext, Context, Div, Entity, - EntityId, EventEmitter, FocusHandle, IntoElement, Model, ParentElement, Pixels, Render, - SharedString, Styled, Subscription, Task, View, ViewContext, VisualContext, WeakView, - WindowContext, + div, point, AnyElement, AppContext, AsyncWindowContext, Context, Div, Entity, EntityId, + EventEmitter, IntoElement, Model, ParentElement, Pixels, Render, SharedString, Styled, + Subscription, Task, View, ViewContext, VisualContext, WeakView, WindowContext, }; use language::{ proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, CharKind, OffsetRangeExt, @@ -20,7 +18,7 @@ use language::{ use project::{search::SearchQuery, FormatTrigger, Item as _, Project, ProjectPath}; use rpc::proto::{self, update_view, PeerId}; use settings::Settings; -use smallvec::SmallVec; + use std::fmt::Write; use std::{ borrow::Cow, @@ -581,7 +579,7 @@ impl Item for Editor { } fn tab_content(&self, detail: Option, selected: bool, cx: &WindowContext) -> AnyElement { - let theme = cx.theme(); + let _theme = cx.theme(); let description = detail.and_then(|detail| { let path = path_for_buffer(&self.buffer, detail, false, cx)?; @@ -697,12 +695,14 @@ impl Item for Editor { })? .await?; for buffer in clean_buffers { - buffer.update(&mut cx, |buffer, cx| { - let version = buffer.saved_version().clone(); - let fingerprint = buffer.saved_version_fingerprint(); - let mtime = buffer.saved_mtime(); - buffer.did_save(version, fingerprint, mtime, cx); - }); + buffer + .update(&mut cx, |buffer, cx| { + let version = buffer.saved_version().clone(); + let fingerprint = buffer.saved_version_fingerprint(); + let mtime = buffer.saved_mtime(); + buffer.did_save(version, fingerprint, mtime, cx); + }) + .ok(); } } @@ -742,13 +742,15 @@ impl Item for Editor { this.update(&mut cx, |editor, cx| { editor.request_autoscroll(Autoscroll::fit(), cx) })?; - buffer.update(&mut cx, |buffer, cx| { - if let Some(transaction) = transaction { - if !buffer.is_singleton() { - buffer.push_transaction(&transaction.0, cx); + buffer + .update(&mut cx, |buffer, cx| { + if let Some(transaction) = transaction { + if !buffer.is_singleton() { + buffer.push_transaction(&transaction.0, cx); + } } - } - }); + }) + .ok(); Ok(()) }) } diff --git a/crates/editor2/src/link_go_to_definition.rs b/crates/editor2/src/link_go_to_definition.rs index ef171277975eda27ef352012079fb872d16178f0..42f502daeda6a308070763bb4bb9936f74aef210 100644 --- a/crates/editor2/src/link_go_to_definition.rs +++ b/crates/editor2/src/link_go_to_definition.rs @@ -618,7 +618,7 @@ mod tests { test::editor_lsp_test_context::EditorLspTestContext, }; use futures::StreamExt; - use gpui::{Modifiers, ModifiersChangedEvent, View}; + use gpui::{Modifiers, ModifiersChangedEvent}; use indoc::indoc; use language::language_settings::InlayHintSettings; use lsp::request::{GotoDefinition, GotoTypeDefinition}; diff --git a/crates/editor2/src/mouse_context_menu.rs b/crates/editor2/src/mouse_context_menu.rs index e6c0fc1111473541a285eaf6d4d41bf87c9952af..24f3b22a5c5648ae5ac2c8befc4989e0404a42a0 100644 --- a/crates/editor2/src/mouse_context_menu.rs +++ b/crates/editor2/src/mouse_context_menu.rs @@ -36,7 +36,7 @@ pub fn deploy_context_menu( s.set_pending_display_range(point..point, SelectMode::Character); }); - let context_menu = ui::ContextMenu::build(cx, |menu, cx| { + let context_menu = ui::ContextMenu::build(cx, |menu, _cx| { menu.action("Rename Symbol", Box::new(Rename)) .action("Go to Definition", Box::new(GoToDefinition)) .action("Go to Type Definition", Box::new(GoToTypeDefinition)) @@ -53,7 +53,7 @@ pub fn deploy_context_menu( let context_menu_focus = context_menu.focus_handle(cx); cx.focus(&context_menu_focus); - let _subscription = cx.subscribe(&context_menu, move |this, _, event: &DismissEvent, cx| { + let _subscription = cx.subscribe(&context_menu, move |this, _, _event: &DismissEvent, cx| { this.mouse_context_menu.take(); if context_menu_focus.contains_focused(cx) { this.focus(cx); @@ -97,7 +97,7 @@ mod tests { do_wˇork(); } "}); - cx.editor(|editor, app| assert!(editor.mouse_context_menu.is_none())); + cx.editor(|editor, _app| assert!(editor.mouse_context_menu.is_none())); cx.update_editor(|editor, cx| deploy_context_menu(editor, Default::default(), point, cx)); cx.assert_editor_state(indoc! {" @@ -105,6 +105,6 @@ mod tests { do_wˇork(); } "}); - cx.editor(|editor, app| assert!(editor.mouse_context_menu.is_some())); + cx.editor(|editor, _app| assert!(editor.mouse_context_menu.is_some())); } } diff --git a/crates/editor2/src/movement.rs b/crates/editor2/src/movement.rs index ab25bb8499aa323178d3573ad563797f1ec0a712..81905869686fd550500cad0b8212717dfec0865f 100644 --- a/crates/editor2/src/movement.rs +++ b/crates/editor2/src/movement.rs @@ -2,7 +2,7 @@ use super::{Bias, DisplayPoint, DisplaySnapshot, SelectionGoal, ToDisplayPoint}; use crate::{char_kind, CharKind, EditorStyle, ToOffset, ToPoint}; use gpui::{px, Pixels, TextSystem}; use language::Point; -use serde::de::IntoDeserializer; + use std::{ops::Range, sync::Arc}; #[derive(Debug, PartialEq)] @@ -757,7 +757,7 @@ mod tests { let mut cx = EditorTestContext::new(cx).await; let editor = cx.editor.clone(); let window = cx.window.clone(); - cx.update_window(window, |_, cx| { + _ = cx.update_window(window, |_, cx| { let text_layout_details = editor.update(cx, |editor, cx| editor.text_layout_details(cx)); diff --git a/crates/editor2/src/rust_analyzer_ext.rs b/crates/editor2/src/rust_analyzer_ext.rs index 0ebf242504098451e34a4d6b7163940055815431..a4e68ff8375b55c3ef65671444c5b4d461f2ee78 100644 --- a/crates/editor2/src/rust_analyzer_ext.rs +++ b/crates/editor2/src/rust_analyzer_ext.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use anyhow::Context as _; -use gpui::{Context, Model, View, ViewContext, VisualContext, WindowContext}; +use gpui::{Context, View, ViewContext, VisualContext, WindowContext}; use language::Language; use multi_buffer::MultiBuffer; use project::lsp_ext_command::ExpandMacro; @@ -91,7 +91,7 @@ pub fn expand_macro_recursively( cx, ) }); - cx.spawn(|editor, mut cx| async move { + cx.spawn(|_editor, mut cx| async move { let macro_expansion = expand_macro_task.await.context("expand macro")?; if macro_expansion.is_empty() { log::info!("Empty macro expansion for position {position:?}"); diff --git a/crates/editor2/src/scroll.rs b/crates/editor2/src/scroll.rs index 208dcc0dd3c9c75755176961386ffceb35892c6b..0798870f76cb37131b86295b57e5f3f01ad22705 100644 --- a/crates/editor2/src/scroll.rs +++ b/crates/editor2/src/scroll.rs @@ -9,7 +9,7 @@ use crate::{ Anchor, DisplayPoint, Editor, EditorEvent, EditorMode, InlayHintRefreshReason, MultiBufferSnapshot, ToPoint, }; -use gpui::{point, px, AppContext, Entity, Pixels, Styled, Task, ViewContext}; +use gpui::{point, px, AppContext, Entity, Pixels, Task, ViewContext}; use language::{Bias, Point}; use std::{ cmp::Ordering, diff --git a/crates/editor2/src/scroll/actions.rs b/crates/editor2/src/scroll/actions.rs index 9a1e54f5e48bc301bd29756b92e20885f2466117..21a4258f6f186700128e081b1ab5d36c3a5938c7 100644 --- a/crates/editor2/src/scroll/actions.rs +++ b/crates/editor2/src/scroll/actions.rs @@ -3,7 +3,7 @@ use crate::{ Autoscroll, Bias, Editor, EditorMode, NextScreen, ScrollAnchor, ScrollCursorBottom, ScrollCursorCenter, ScrollCursorTop, }; -use gpui::{actions, AppContext, Point, ViewContext}; +use gpui::{Point, ViewContext}; impl Editor { pub fn next_screen(&mut self, _: &NextScreen, cx: &mut ViewContext) { diff --git a/crates/editor2/src/scroll/autoscroll.rs b/crates/editor2/src/scroll/autoscroll.rs index 9315d5c0997fd649e8c0f16cc5425cca1803a8f4..ba70739942c429e6b5eb11139a395b98db38475a 100644 --- a/crates/editor2/src/scroll/autoscroll.rs +++ b/crates/editor2/src/scroll/autoscroll.rs @@ -61,7 +61,7 @@ impl Editor { display_map.max_point().row() as f32 }; if scroll_position.y > max_scroll_top { - scroll_position.y = (max_scroll_top); + scroll_position.y = max_scroll_top; self.set_scroll_position(scroll_position, cx); } @@ -143,24 +143,24 @@ impl Editor { let needs_scroll_down = target_bottom >= end_row; if needs_scroll_up && !needs_scroll_down { - scroll_position.y = (target_top); + scroll_position.y = target_top; self.set_scroll_position_internal(scroll_position, local, true, cx); } if !needs_scroll_up && needs_scroll_down { - scroll_position.y = (target_bottom - visible_lines); + scroll_position.y = target_bottom - visible_lines; self.set_scroll_position_internal(scroll_position, local, true, cx); } } AutoscrollStrategy::Center => { - scroll_position.y = ((target_top - margin).max(0.0)); + scroll_position.y = (target_top - margin).max(0.0); self.set_scroll_position_internal(scroll_position, local, true, cx); } AutoscrollStrategy::Top => { - scroll_position.y = ((target_top).max(0.0)); + scroll_position.y = (target_top).max(0.0); self.set_scroll_position_internal(scroll_position, local, true, cx); } AutoscrollStrategy::Bottom => { - scroll_position.y = ((target_bottom - visible_lines).max(0.0)); + scroll_position.y = (target_bottom - visible_lines).max(0.0); self.set_scroll_position_internal(scroll_position, local, true, cx); } } diff --git a/crates/editor2/src/test/editor_test_context.rs b/crates/editor2/src/test/editor_test_context.rs index 0b6fb69d71b27089f6bce4a00d4492fbd8161629..bd5acb99459c131d316a5376688f3d4bcb81da93 100644 --- a/crates/editor2/src/test/editor_test_context.rs +++ b/crates/editor2/src/test/editor_test_context.rs @@ -4,8 +4,7 @@ use crate::{ use collections::BTreeMap; use futures::Future; use gpui::{ - AnyWindowHandle, AppContext, ForegroundExecutor, Keystroke, ModelContext, View, ViewContext, - VisualTestContext, WindowHandle, + AnyWindowHandle, AppContext, Keystroke, ModelContext, View, ViewContext, VisualTestContext, }; use indoc::indoc; use itertools::Itertools; diff --git a/crates/workspace2/src/persistence.rs b/crates/workspace2/src/persistence.rs index 1abb06dccfa712c97b626dafd1e8c1feb251ddb6..5358ee3f4c656e732a29c061593c6ff55eee7aed 100644 --- a/crates/workspace2/src/persistence.rs +++ b/crates/workspace2/src/persistence.rs @@ -1,4 +1,4 @@ -#![allow(dead_code)] +//#![allow(dead_code)] pub mod model; diff --git a/crates/zed2/src/open_listener.rs b/crates/zed2/src/open_listener.rs index b45254f7174c600f27ff552fef8ae7c2a2be7446..6db020a785788d1fe0d05cd2a4d10d937f2b5ac4 100644 --- a/crates/zed2/src/open_listener.rs +++ b/crates/zed2/src/open_listener.rs @@ -251,12 +251,11 @@ pub async fn handle_cli_connection( let wait = async move { if paths.is_empty() { let (done_tx, done_rx) = oneshot::channel(); - let _subscription = - workspace.update(&mut cx, |workspace, cx| { - cx.on_release(move |_, _, _| { - let _ = done_tx.send(()); - }) - }); + let _subscription = workspace.update(&mut cx, |_, cx| { + cx.on_release(move |_, _, _| { + let _ = done_tx.send(()); + }) + }); let _ = done_rx.await; } else { let _ = futures::future::try_join_all(item_release_futures) diff --git a/crates/zed2/src/zed2.rs b/crates/zed2/src/zed2.rs index aa21a3e9955defc8cb623b163851ecd8156dc5c5..4abc81cf37313824d6fd955894cbefed716c987d 100644 --- a/crates/zed2/src/zed2.rs +++ b/crates/zed2/src/zed2.rs @@ -1,6 +1,3 @@ -#![allow(unused_variables, unused_mut)] -//todo!() - mod app_menus; mod assets; pub mod languages; @@ -37,9 +34,8 @@ use util::{ use uuid::Uuid; use workspace::Pane; use workspace::{ - create_and_open_local_file, dock::PanelHandle, - notifications::simple_message_notification::MessageNotification, open_new, AppState, NewFile, - NewWindow, Workspace, WorkspaceSettings, + create_and_open_local_file, notifications::simple_message_notification::MessageNotification, + open_new, AppState, NewFile, NewWindow, Workspace, WorkspaceSettings, }; use zed_actions::{OpenBrowser, OpenSettings, OpenZedURL, Quit}; @@ -184,7 +180,6 @@ pub fn initialize_workspace(app_state: Arc, cx: &mut AppContext) { )?; workspace_handle.update(&mut cx, |workspace, cx| { - let project_panel_position = project_panel.position(cx); workspace.add_panel(project_panel, cx); workspace.add_panel(terminal_panel, cx); workspace.add_panel(assistant_panel, cx); @@ -473,7 +468,7 @@ fn quit(_: &mut Workspace, _: &Quit, cx: &mut gpui::ViewContext) { }) .log_err(); - if let (true, Some(window)) = (should_confirm, workspace_windows.first().copied()) { + if let (true, Some(_)) = (should_confirm, workspace_windows.first().copied()) { let answer = cx .update(|_, cx| { cx.prompt( @@ -484,7 +479,7 @@ fn quit(_: &mut Workspace, _: &Quit, cx: &mut gpui::ViewContext) { }) .log_err(); - if let Some(mut answer) = answer { + if let Some(answer) = answer { let answer = answer.await.ok(); if answer != Some(0) { return Ok(());