lints: A bunch of extra style lint fixes (#36568)

- **lints: Fix 'doc_lazy_continuation'**
- **lints: Fix 'doc_overindented_list_items'**
- **inherent_to_string and io_other_error**
- **Some more lint fixes**
- **lints: enable bool_assert_comparison, match_like_matches_macro and
wrong_self_convention**


Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-20 12:05:58 +02:00 committed by GitHub
parent a32a264508
commit cf7c64d77f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
92 changed files with 277 additions and 345 deletions

View file

@ -822,15 +822,21 @@ single_range_in_vec_init = "allow"
style = { level = "allow", priority = -1 } style = { level = "allow", priority = -1 }
# Temporary list of style lints that we've fixed so far. # Temporary list of style lints that we've fixed so far.
bool_assert_comparison = "warn"
comparison_to_empty = "warn" comparison_to_empty = "warn"
doc_lazy_continuation = "warn"
doc_overindented_list_items = "warn"
inherent_to_string = "warn"
for_kv_map = "warn" for_kv_map = "warn"
into_iter_on_ref = "warn" into_iter_on_ref = "warn"
io_other_error = "warn"
iter_cloned_collect = "warn" iter_cloned_collect = "warn"
iter_next_slice = "warn" iter_next_slice = "warn"
iter_nth = "warn" iter_nth = "warn"
iter_nth_zero = "warn" iter_nth_zero = "warn"
iter_skip_next = "warn" iter_skip_next = "warn"
let_and_return = "warn" let_and_return = "warn"
match_like_matches_macro = "warn"
module_inception = { level = "deny" } module_inception = { level = "deny" }
question_mark = { level = "deny" } question_mark = { level = "deny" }
single_match = "warn" single_match = "warn"
@ -846,6 +852,7 @@ needless_return = { level = "warn" }
unnecessary_mut_passed = {level = "warn"} unnecessary_mut_passed = {level = "warn"}
unnecessary_map_or = { level = "warn" } unnecessary_map_or = { level = "warn" }
unused_unit = "warn" unused_unit = "warn"
wrong_self_convention = "warn"
# Individual rules that have violations in the codebase: # Individual rules that have violations in the codebase:
type_complexity = "allow" type_complexity = "allow"

View file

@ -254,10 +254,9 @@ impl HistoryStore {
} }
pub fn remove_recently_opened_thread(&mut self, id: ThreadId, cx: &mut Context<Self>) { pub fn remove_recently_opened_thread(&mut self, id: ThreadId, cx: &mut Context<Self>) {
self.recently_opened_entries.retain(|entry| match entry { self.recently_opened_entries.retain(
HistoryEntryId::Thread(thread_id) if thread_id == &id => false, |entry| !matches!(entry, HistoryEntryId::Thread(thread_id) if thread_id == &id),
_ => true, );
});
self.save_recently_opened_entries(cx); self.save_recently_opened_entries(cx);
} }

View file

@ -181,7 +181,7 @@ impl Message {
} }
} }
pub fn to_string(&self) -> String { pub fn to_message_content(&self) -> String {
let mut result = String::new(); let mut result = String::new();
if !self.loaded_context.text.is_empty() { if !self.loaded_context.text.is_empty() {
@ -2823,7 +2823,7 @@ impl Thread {
let message_content = self let message_content = self
.message(message_id) .message(message_id)
.map(|msg| msg.to_string()) .map(|msg| msg.to_message_content())
.unwrap_or_default(); .unwrap_or_default();
cx.background_spawn(async move { cx.background_spawn(async move {

View file

@ -312,10 +312,9 @@ impl HistoryStore {
} }
pub fn remove_recently_opened_thread(&mut self, id: acp::SessionId, cx: &mut Context<Self>) { pub fn remove_recently_opened_thread(&mut self, id: acp::SessionId, cx: &mut Context<Self>) {
self.recently_opened_entries.retain(|entry| match entry { self.recently_opened_entries.retain(
HistoryEntryId::AcpThread(thread_id) if thread_id == &id => false, |entry| !matches!(entry, HistoryEntryId::AcpThread(thread_id) if thread_id == &id),
_ => true, );
});
self.save_recently_opened_entries(cx); self.save_recently_opened_entries(cx);
} }

View file

@ -505,9 +505,8 @@ impl Settings for AgentSettings {
} }
} }
debug_assert_eq!( debug_assert!(
sources.default.always_allow_tool_actions.unwrap_or(false), !sources.default.always_allow_tool_actions.unwrap_or(false),
false,
"For security, agent.always_allow_tool_actions should always be false in default.json. If it's true, that is a bug that should be fixed!" "For security, agent.always_allow_tool_actions should always be false in default.json. If it's true, that is a bug that should be fixed!"
); );

View file

@ -1765,7 +1765,7 @@ impl ActiveThread {
.thread .thread
.read(cx) .read(cx)
.message(message_id) .message(message_id)
.map(|msg| msg.to_string()) .map(|msg| msg.to_message_content())
.unwrap_or_default(); .unwrap_or_default();
telemetry::event!( telemetry::event!(

View file

@ -668,10 +668,10 @@ mod tests {
); );
let parsed_model = model_input.parse(cx).unwrap(); let parsed_model = model_input.parse(cx).unwrap();
assert_eq!(parsed_model.capabilities.tools, true); assert!(parsed_model.capabilities.tools);
assert_eq!(parsed_model.capabilities.images, false); assert!(!parsed_model.capabilities.images);
assert_eq!(parsed_model.capabilities.parallel_tool_calls, false); assert!(!parsed_model.capabilities.parallel_tool_calls);
assert_eq!(parsed_model.capabilities.prompt_cache_key, false); assert!(!parsed_model.capabilities.prompt_cache_key);
}); });
} }
@ -693,10 +693,10 @@ mod tests {
model_input.capabilities.supports_prompt_cache_key = ToggleState::Unselected; model_input.capabilities.supports_prompt_cache_key = ToggleState::Unselected;
let parsed_model = model_input.parse(cx).unwrap(); let parsed_model = model_input.parse(cx).unwrap();
assert_eq!(parsed_model.capabilities.tools, false); assert!(!parsed_model.capabilities.tools);
assert_eq!(parsed_model.capabilities.images, false); assert!(!parsed_model.capabilities.images);
assert_eq!(parsed_model.capabilities.parallel_tool_calls, false); assert!(!parsed_model.capabilities.parallel_tool_calls);
assert_eq!(parsed_model.capabilities.prompt_cache_key, false); assert!(!parsed_model.capabilities.prompt_cache_key);
}); });
} }
@ -719,10 +719,10 @@ mod tests {
let parsed_model = model_input.parse(cx).unwrap(); let parsed_model = model_input.parse(cx).unwrap();
assert_eq!(parsed_model.name, "somemodel"); assert_eq!(parsed_model.name, "somemodel");
assert_eq!(parsed_model.capabilities.tools, true); assert!(parsed_model.capabilities.tools);
assert_eq!(parsed_model.capabilities.images, false); assert!(!parsed_model.capabilities.images);
assert_eq!(parsed_model.capabilities.parallel_tool_calls, true); assert!(parsed_model.capabilities.parallel_tool_calls);
assert_eq!(parsed_model.capabilities.prompt_cache_key, false); assert!(!parsed_model.capabilities.prompt_cache_key);
}); });
} }

View file

@ -1436,6 +1436,6 @@ impl SlashCommand for FakeSlashCommand {
sections: vec![], sections: vec![],
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream())) .into_event_stream()))
} }
} }

View file

@ -161,7 +161,7 @@ impl SlashCommandOutput {
} }
/// Returns this [`SlashCommandOutput`] as a stream of [`SlashCommandEvent`]s. /// Returns this [`SlashCommandOutput`] as a stream of [`SlashCommandEvent`]s.
pub fn to_event_stream(mut self) -> BoxStream<'static, Result<SlashCommandEvent>> { pub fn into_event_stream(mut self) -> BoxStream<'static, Result<SlashCommandEvent>> {
self.ensure_valid_section_ranges(); self.ensure_valid_section_ranges();
let mut events = Vec::new(); let mut events = Vec::new();
@ -363,7 +363,7 @@ mod tests {
run_commands_in_text: false, run_commands_in_text: false,
}; };
let events = output.clone().to_event_stream().collect::<Vec<_>>().await; let events = output.clone().into_event_stream().collect::<Vec<_>>().await;
let events = events let events = events
.into_iter() .into_iter()
.filter_map(|event| event.ok()) .filter_map(|event| event.ok())
@ -386,7 +386,7 @@ mod tests {
); );
let new_output = let new_output =
SlashCommandOutput::from_event_stream(output.clone().to_event_stream()) SlashCommandOutput::from_event_stream(output.clone().into_event_stream())
.await .await
.unwrap(); .unwrap();
@ -415,7 +415,7 @@ mod tests {
run_commands_in_text: false, run_commands_in_text: false,
}; };
let events = output.clone().to_event_stream().collect::<Vec<_>>().await; let events = output.clone().into_event_stream().collect::<Vec<_>>().await;
let events = events let events = events
.into_iter() .into_iter()
.filter_map(|event| event.ok()) .filter_map(|event| event.ok())
@ -452,7 +452,7 @@ mod tests {
); );
let new_output = let new_output =
SlashCommandOutput::from_event_stream(output.clone().to_event_stream()) SlashCommandOutput::from_event_stream(output.clone().into_event_stream())
.await .await
.unwrap(); .unwrap();
@ -493,7 +493,7 @@ mod tests {
run_commands_in_text: false, run_commands_in_text: false,
}; };
let events = output.clone().to_event_stream().collect::<Vec<_>>().await; let events = output.clone().into_event_stream().collect::<Vec<_>>().await;
let events = events let events = events
.into_iter() .into_iter()
.filter_map(|event| event.ok()) .filter_map(|event| event.ok())
@ -562,7 +562,7 @@ mod tests {
); );
let new_output = let new_output =
SlashCommandOutput::from_event_stream(output.clone().to_event_stream()) SlashCommandOutput::from_event_stream(output.clone().into_event_stream())
.await .await
.unwrap(); .unwrap();

View file

@ -166,7 +166,7 @@ impl SlashCommand for ExtensionSlashCommand {
.collect(), .collect(),
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream()) .into_event_stream())
}) })
} }
} }

View file

@ -150,7 +150,7 @@ impl SlashCommand for CargoWorkspaceSlashCommand {
}], }],
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream()) .into_event_stream())
}) })
}); });
output.unwrap_or_else(|error| Task::ready(Err(error))) output.unwrap_or_else(|error| Task::ready(Err(error)))

View file

@ -191,7 +191,7 @@ impl SlashCommand for ContextServerSlashCommand {
text: prompt, text: prompt,
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream()) .into_event_stream())
}) })
} else { } else {
Task::ready(Err(anyhow!("Context server not found"))) Task::ready(Err(anyhow!("Context server not found")))

View file

@ -85,7 +85,7 @@ impl SlashCommand for DefaultSlashCommand {
text, text,
run_commands_in_text: true, run_commands_in_text: true,
} }
.to_event_stream()) .into_event_stream())
}) })
} }
} }

View file

@ -118,7 +118,7 @@ impl SlashCommand for DeltaSlashCommand {
} }
anyhow::ensure!(changes_detected, "no new changes detected"); anyhow::ensure!(changes_detected, "no new changes detected");
Ok(output.to_event_stream()) Ok(output.into_event_stream())
}) })
} }
} }

View file

@ -189,7 +189,7 @@ impl SlashCommand for DiagnosticsSlashCommand {
window.spawn(cx, async move |_| { window.spawn(cx, async move |_| {
task.await? task.await?
.map(|output| output.to_event_stream()) .map(|output| output.into_event_stream())
.context("No diagnostics found") .context("No diagnostics found")
}) })
} }

View file

@ -177,7 +177,7 @@ impl SlashCommand for FetchSlashCommand {
}], }],
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream()) .into_event_stream())
}) })
} }
} }

View file

@ -371,7 +371,7 @@ fn collect_files(
&mut output, &mut output,
) )
.log_err(); .log_err();
let mut buffer_events = output.to_event_stream(); let mut buffer_events = output.into_event_stream();
while let Some(event) = buffer_events.next().await { while let Some(event) = buffer_events.next().await {
events_tx.unbounded_send(event)?; events_tx.unbounded_send(event)?;
} }

View file

@ -66,6 +66,6 @@ impl SlashCommand for NowSlashCommand {
}], }],
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream())) .into_event_stream()))
} }
} }

View file

@ -117,7 +117,7 @@ impl SlashCommand for PromptSlashCommand {
}], }],
run_commands_in_text: true, run_commands_in_text: true,
} }
.to_event_stream()) .into_event_stream())
}) })
} }
} }

View file

@ -92,7 +92,7 @@ impl SlashCommand for OutlineSlashCommand {
text: outline_text, text: outline_text,
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream()) .into_event_stream())
}) })
}); });

View file

@ -157,7 +157,7 @@ impl SlashCommand for TabSlashCommand {
for (full_path, buffer, _) in tab_items_search.await? { for (full_path, buffer, _) in tab_items_search.await? {
append_buffer_to_output(&buffer, full_path.as_deref(), &mut output).log_err(); append_buffer_to_output(&buffer, full_path.as_deref(), &mut output).log_err();
} }
Ok(output.to_event_stream()) Ok(output.into_event_stream())
}) })
} }
} }

View file

@ -128,23 +128,20 @@ mod windows_impl {
#[test] #[test]
fn test_parse_args() { fn test_parse_args() {
// launch can be specified via two separate arguments // launch can be specified via two separate arguments
assert_eq!(parse_args(["--launch".into(), "true".into()]).launch, true); assert!(parse_args(["--launch".into(), "true".into()]).launch);
assert_eq!( assert!(!parse_args(["--launch".into(), "false".into()]).launch);
parse_args(["--launch".into(), "false".into()]).launch,
false
);
// launch can be specified via one single argument // launch can be specified via one single argument
assert_eq!(parse_args(["--launch=true".into()]).launch, true); assert!(parse_args(["--launch=true".into()]).launch);
assert_eq!(parse_args(["--launch=false".into()]).launch, false); assert!(!parse_args(["--launch=false".into()]).launch);
// launch defaults to true on no arguments // launch defaults to true on no arguments
assert_eq!(parse_args([]).launch, true); assert!(parse_args([]).launch);
// launch defaults to true on invalid arguments // launch defaults to true on invalid arguments
assert_eq!(parse_args(["--launch".into()]).launch, true); assert!(parse_args(["--launch".into()]).launch);
assert_eq!(parse_args(["--launch=".into()]).launch, true); assert!(parse_args(["--launch=".into()]).launch);
assert_eq!(parse_args(["--launch=invalid".into()]).launch, true); assert!(parse_args(["--launch=invalid".into()]).launch);
} }
} }
} }

View file

@ -90,11 +90,7 @@ pub(crate) const JOBS: [Job; 2] = [
std::thread::sleep(Duration::from_millis(1000)); std::thread::sleep(Duration::from_millis(1000));
if let Ok(config) = std::env::var("ZED_AUTO_UPDATE") { if let Ok(config) = std::env::var("ZED_AUTO_UPDATE") {
match config.as_str() { match config.as_str() {
"err" => Err(std::io::Error::new( "err" => Err(std::io::Error::other("Simulated error")).context("Anyhow!"),
std::io::ErrorKind::Other,
"Simulated error",
))
.context("Anyhow!"),
_ => panic!("Unknown ZED_AUTO_UPDATE value: {}", config), _ => panic!("Unknown ZED_AUTO_UPDATE value: {}", config),
} }
} else { } else {
@ -105,11 +101,7 @@ pub(crate) const JOBS: [Job; 2] = [
std::thread::sleep(Duration::from_millis(1000)); std::thread::sleep(Duration::from_millis(1000));
if let Ok(config) = std::env::var("ZED_AUTO_UPDATE") { if let Ok(config) = std::env::var("ZED_AUTO_UPDATE") {
match config.as_str() { match config.as_str() {
"err" => Err(std::io::Error::new( "err" => Err(std::io::Error::other("Simulated error")).context("Anyhow!"),
std::io::ErrorKind::Other,
"Simulated error",
))
.context("Anyhow!"),
_ => panic!("Unknown ZED_AUTO_UPDATE value: {}", config), _ => panic!("Unknown ZED_AUTO_UPDATE value: {}", config),
} }
} else { } else {

View file

@ -41,7 +41,7 @@ impl std::fmt::Display for ChannelId {
pub struct ProjectId(pub u64); pub struct ProjectId(pub u64);
impl ProjectId { impl ProjectId {
pub fn to_proto(&self) -> u64 { pub fn to_proto(self) -> u64 {
self.0 self.0
} }
} }

View file

@ -685,7 +685,7 @@ impl LocalSettingsKind {
} }
} }
pub fn to_proto(&self) -> proto::LocalSettingsKind { pub fn to_proto(self) -> proto::LocalSettingsKind {
match self { match self {
Self::Settings => proto::LocalSettingsKind::Settings, Self::Settings => proto::LocalSettingsKind::Settings,
Self::Tasks => proto::LocalSettingsKind::Tasks, Self::Tasks => proto::LocalSettingsKind::Tasks,

View file

@ -3208,7 +3208,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
worktree_a.read_with(cx_a, |worktree, _| { worktree_a.read_with(cx_a, |worktree, _| {
@ -3237,7 +3237,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
worktree_a.read_with(cx_a, |worktree, _| { worktree_a.read_with(cx_a, |worktree, _| {
@ -3266,7 +3266,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
worktree_a.read_with(cx_a, |worktree, _| { worktree_a.read_with(cx_a, |worktree, _| {
@ -3295,7 +3295,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
project_b project_b
@ -3304,7 +3304,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
project_b project_b
@ -3313,7 +3313,7 @@ async fn test_fs_operations(
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
worktree_a.read_with(cx_a, |worktree, _| { worktree_a.read_with(cx_a, |worktree, _| {

View file

@ -897,7 +897,7 @@ impl TestClient {
let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap()); let window = cx.update(|cx| cx.active_window().unwrap().downcast::<Workspace>().unwrap());
let entity = window.root(cx).unwrap(); let entity = window.root(cx).unwrap();
let cx = VisualTestContext::from_window(*window.deref(), cx).as_mut(); let cx = VisualTestContext::from_window(*window.deref(), cx).into_mut();
// it might be nice to try and cleanup these at the end of each test. // it might be nice to try and cleanup these at the end of each test.
(entity, cx) (entity, cx)
} }

View file

@ -1821,10 +1821,10 @@ impl CollabPanel {
} }
fn select_channel_editor(&mut self) { fn select_channel_editor(&mut self) {
self.selection = self.entries.iter().position(|entry| match entry { self.selection = self
ListEntry::ChannelEditor { .. } => true, .entries
_ => false, .iter()
}); .position(|entry| matches!(entry, ListEntry::ChannelEditor { .. }));
} }
fn new_subchannel( fn new_subchannel(

View file

@ -67,11 +67,7 @@ pub(crate) struct Client {
pub(crate) struct ContextServerId(pub Arc<str>); pub(crate) struct ContextServerId(pub Arc<str>);
fn is_null_value<T: Serialize>(value: &T) -> bool { fn is_null_value<T: Serialize>(value: &T) -> bool {
if let Ok(Value::Null) = serde_json::to_value(value) { matches!(serde_json::to_value(value), Ok(Value::Null))
true
} else {
false
}
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]

View file

@ -23,7 +23,7 @@ impl SessionId {
Self(client_id as u32) Self(client_id as u32)
} }
pub fn to_proto(&self) -> u64 { pub fn to_proto(self) -> u64 {
self.0 as u64 self.0 as u64
} }
} }

View file

@ -2868,12 +2868,7 @@ mod tests {
1, 1,
blocks blocks
.iter() .iter()
.filter(|(_, block)| { .filter(|(_, block)| { matches!(block, Block::FoldedBuffer { .. }) })
match block {
Block::FoldedBuffer { .. } => true,
_ => false,
}
})
.count(), .count(),
"Should have one folded block, producing a header of the second buffer" "Should have one folded block, producing a header of the second buffer"
); );

View file

@ -782,10 +782,7 @@ impl MinimapVisibility {
} }
fn disabled(&self) -> bool { fn disabled(&self) -> bool {
match *self { matches!(*self, Self::Disabled)
Self::Disabled => true,
_ => false,
}
} }
fn settings_visibility(&self) -> bool { fn settings_visibility(&self) -> bool {

View file

@ -293,7 +293,7 @@ impl FollowableItem for Editor {
EditorEvent::ExcerptsRemoved { ids, .. } => { EditorEvent::ExcerptsRemoved { ids, .. } => {
update update
.deleted_excerpts .deleted_excerpts
.extend(ids.iter().map(ExcerptId::to_proto)); .extend(ids.iter().copied().map(ExcerptId::to_proto));
true true
} }
EditorEvent::ScrollPositionChanged { autoscroll, .. } if !autoscroll => { EditorEvent::ScrollPositionChanged { autoscroll, .. } if !autoscroll => {

View file

@ -67,10 +67,7 @@ impl ScrollAmount {
} }
pub fn is_full_page(&self) -> bool { pub fn is_full_page(&self) -> bool {
match self { matches!(self, ScrollAmount::Page(count) if count.abs() == 1.0)
ScrollAmount::Page(count) if count.abs() == 1.0 => true,
_ => false,
}
} }
pub fn direction(&self) -> ScrollDirection { pub fn direction(&self) -> ScrollDirection {

View file

@ -300,6 +300,7 @@ impl EditorLspTestContext {
self.to_lsp_range(ranges[0].clone()) self.to_lsp_range(ranges[0].clone())
} }
#[expect(clippy::wrong_self_convention, reason = "This is test code")]
pub fn to_lsp_range(&mut self, range: Range<usize>) -> lsp::Range { pub fn to_lsp_range(&mut self, range: Range<usize>) -> lsp::Range {
let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx)); let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx));
let start_point = range.start.to_point(&snapshot.buffer_snapshot); let start_point = range.start.to_point(&snapshot.buffer_snapshot);
@ -326,6 +327,7 @@ impl EditorLspTestContext {
}) })
} }
#[expect(clippy::wrong_self_convention, reason = "This is test code")]
pub fn to_lsp(&mut self, offset: usize) -> lsp::Position { pub fn to_lsp(&mut self, offset: usize) -> lsp::Position {
let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx)); let snapshot = self.update_editor(|editor, window, cx| editor.snapshot(window, cx));
let point = offset.to_point(&snapshot.buffer_snapshot); let point = offset.to_point(&snapshot.buffer_snapshot);

View file

@ -335,7 +335,7 @@ impl ExampleContext {
for message in thread.messages().skip(message_count_before) { for message in thread.messages().skip(message_count_before) {
messages.push(Message { messages.push(Message {
_role: message.role, _role: message.role,
text: message.to_string(), text: message.to_message_content(),
tool_use: thread tool_use: thread
.tool_uses_for_message(message.id, cx) .tool_uses_for_message(message.id, cx)
.into_iter() .into_iter()

View file

@ -1192,7 +1192,7 @@ mod test {
output.analysis, output.analysis,
Some("The model did a good job but there were still compilations errors.".into()) Some("The model did a good job but there were still compilations errors.".into())
); );
assert_eq!(output.passed, true); assert!(output.passed);
let response = r#" let response = r#"
Text around ignored Text around ignored
@ -1212,6 +1212,6 @@ mod test {
output.analysis, output.analysis,
Some("Failed to compile:\n- Error 1\n- Error 2".into()) Some("Failed to compile:\n- Error 1\n- Error 2".into())
); );
assert_eq!(output.passed, false); assert!(!output.passed);
} }
} }

View file

@ -153,17 +153,11 @@ impl FileStatus {
} }
pub fn is_conflicted(self) -> bool { pub fn is_conflicted(self) -> bool {
match self { matches!(self, FileStatus::Unmerged { .. })
FileStatus::Unmerged { .. } => true,
_ => false,
}
} }
pub fn is_ignored(self) -> bool { pub fn is_ignored(self) -> bool {
match self { matches!(self, FileStatus::Ignored)
FileStatus::Ignored => true,
_ => false,
}
} }
pub fn has_changes(&self) -> bool { pub fn has_changes(&self) -> bool {
@ -176,40 +170,31 @@ impl FileStatus {
pub fn is_modified(self) -> bool { pub fn is_modified(self) -> bool {
match self { match self {
FileStatus::Tracked(tracked) => match (tracked.index_status, tracked.worktree_status) { FileStatus::Tracked(tracked) => matches!(
(StatusCode::Modified, _) | (_, StatusCode::Modified) => true, (tracked.index_status, tracked.worktree_status),
_ => false, (StatusCode::Modified, _) | (_, StatusCode::Modified)
}, ),
_ => false, _ => false,
} }
} }
pub fn is_created(self) -> bool { pub fn is_created(self) -> bool {
match self { match self {
FileStatus::Tracked(tracked) => match (tracked.index_status, tracked.worktree_status) { FileStatus::Tracked(tracked) => matches!(
(StatusCode::Added, _) | (_, StatusCode::Added) => true, (tracked.index_status, tracked.worktree_status),
_ => false, (StatusCode::Added, _) | (_, StatusCode::Added)
}, ),
FileStatus::Untracked => true, FileStatus::Untracked => true,
_ => false, _ => false,
} }
} }
pub fn is_deleted(self) -> bool { pub fn is_deleted(self) -> bool {
match self { matches!(self, FileStatus::Tracked(tracked) if matches!((tracked.index_status, tracked.worktree_status), (StatusCode::Deleted, _) | (_, StatusCode::Deleted)))
FileStatus::Tracked(tracked) => match (tracked.index_status, tracked.worktree_status) {
(StatusCode::Deleted, _) | (_, StatusCode::Deleted) => true,
_ => false,
},
_ => false,
}
} }
pub fn is_untracked(self) -> bool { pub fn is_untracked(self) -> bool {
match self { matches!(self, FileStatus::Untracked)
FileStatus::Untracked => true,
_ => false,
}
} }
pub fn summary(self) -> GitSummary { pub fn summary(self) -> GitSummary {

View file

@ -1070,8 +1070,7 @@ pub struct ProjectDiffEmptyState {
impl RenderOnce for ProjectDiffEmptyState { impl RenderOnce for ProjectDiffEmptyState {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement { fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
let status_against_remote = |ahead_by: usize, behind_by: usize| -> bool { let status_against_remote = |ahead_by: usize, behind_by: usize| -> bool {
match self.current_branch { matches!(self.current_branch, Some(Branch {
Some(Branch {
upstream: upstream:
Some(Upstream { Some(Upstream {
tracking: tracking:
@ -1081,9 +1080,7 @@ impl RenderOnce for ProjectDiffEmptyState {
.. ..
}), }),
.. ..
}) if (ahead > 0) == (ahead_by > 0) && (behind > 0) == (behind_by > 0) => true, }) if (ahead > 0) == (ahead_by > 0) && (behind > 0) == (behind_by > 0))
_ => false,
}
}; };
let change_count = |current_branch: &Branch| -> (usize, usize) { let change_count = |current_branch: &Branch| -> (usize, usize) {

View file

@ -192,6 +192,7 @@ impl TestAppContext {
&self.foreground_executor &self.foreground_executor
} }
#[expect(clippy::wrong_self_convention)]
fn new<T: 'static>(&mut self, build_entity: impl FnOnce(&mut Context<T>) -> T) -> Entity<T> { fn new<T: 'static>(&mut self, build_entity: impl FnOnce(&mut Context<T>) -> T) -> Entity<T> {
let mut cx = self.app.borrow_mut(); let mut cx = self.app.borrow_mut();
cx.new(build_entity) cx.new(build_entity)
@ -244,7 +245,7 @@ impl TestAppContext {
) )
.unwrap(); .unwrap();
drop(cx); drop(cx);
let cx = VisualTestContext::from_window(*window.deref(), self).as_mut(); let cx = VisualTestContext::from_window(*window.deref(), self).into_mut();
cx.run_until_parked(); cx.run_until_parked();
cx cx
} }
@ -273,7 +274,7 @@ impl TestAppContext {
.unwrap(); .unwrap();
drop(cx); drop(cx);
let view = window.root(self).unwrap(); let view = window.root(self).unwrap();
let cx = VisualTestContext::from_window(*window.deref(), self).as_mut(); let cx = VisualTestContext::from_window(*window.deref(), self).into_mut();
cx.run_until_parked(); cx.run_until_parked();
// it might be nice to try and cleanup these at the end of each test. // it might be nice to try and cleanup these at the end of each test.
@ -882,7 +883,7 @@ impl VisualTestContext {
/// Get an &mut VisualTestContext (which is mostly what you need to pass to other methods). /// Get an &mut VisualTestContext (which is mostly what you need to pass to other methods).
/// This method internally retains the VisualTestContext until the end of the test. /// This method internally retains the VisualTestContext until the end of the test.
pub fn as_mut(self) -> &'static mut Self { pub fn into_mut(self) -> &'static mut Self {
let ptr = Box::into_raw(Box::new(self)); let ptr = Box::into_raw(Box::new(self));
// safety: on_quit will be called after the test has finished. // safety: on_quit will be called after the test has finished.
// the executor will ensure that all tasks related to the test have stopped. // the executor will ensure that all tasks related to the test have stopped.

View file

@ -905,9 +905,9 @@ mod tests {
assert_eq!(background.solid, color); assert_eq!(background.solid, color);
assert_eq!(background.opacity(0.5).solid, color.opacity(0.5)); assert_eq!(background.opacity(0.5).solid, color.opacity(0.5));
assert_eq!(background.is_transparent(), false); assert!(!background.is_transparent());
background.solid = hsla(0.0, 0.0, 0.0, 0.0); background.solid = hsla(0.0, 0.0, 0.0, 0.0);
assert_eq!(background.is_transparent(), true); assert!(background.is_transparent());
} }
#[test] #[test]
@ -921,7 +921,7 @@ mod tests {
assert_eq!(background.opacity(0.5).colors[0], from.opacity(0.5)); assert_eq!(background.opacity(0.5).colors[0], from.opacity(0.5));
assert_eq!(background.opacity(0.5).colors[1], to.opacity(0.5)); assert_eq!(background.opacity(0.5).colors[1], to.opacity(0.5));
assert_eq!(background.is_transparent(), false); assert!(!background.is_transparent());
assert_eq!(background.opacity(0.0).is_transparent(), true); assert!(background.opacity(0.0).is_transparent());
} }
} }

View file

@ -1641,7 +1641,7 @@ impl Bounds<Pixels> {
} }
/// Convert the bounds from logical pixels to physical pixels /// Convert the bounds from logical pixels to physical pixels
pub fn to_device_pixels(&self, factor: f32) -> Bounds<DevicePixels> { pub fn to_device_pixels(self, factor: f32) -> Bounds<DevicePixels> {
Bounds { Bounds {
origin: point( origin: point(
DevicePixels((self.origin.x.0 * factor).round() as i32), DevicePixels((self.origin.x.0 * factor).round() as i32),
@ -1957,7 +1957,7 @@ impl Edges<DefiniteLength> {
/// assert_eq!(edges_in_pixels.bottom, px(32.0)); // 2 rems /// assert_eq!(edges_in_pixels.bottom, px(32.0)); // 2 rems
/// assert_eq!(edges_in_pixels.left, px(50.0)); // 25% of parent width /// assert_eq!(edges_in_pixels.left, px(50.0)); // 25% of parent width
/// ``` /// ```
pub fn to_pixels(&self, parent_size: Size<AbsoluteLength>, rem_size: Pixels) -> Edges<Pixels> { pub fn to_pixels(self, parent_size: Size<AbsoluteLength>, rem_size: Pixels) -> Edges<Pixels> {
Edges { Edges {
top: self.top.to_pixels(parent_size.height, rem_size), top: self.top.to_pixels(parent_size.height, rem_size),
right: self.right.to_pixels(parent_size.width, rem_size), right: self.right.to_pixels(parent_size.width, rem_size),
@ -2027,7 +2027,7 @@ impl Edges<AbsoluteLength> {
/// assert_eq!(edges_in_pixels.bottom, px(20.0)); // Already in pixels /// assert_eq!(edges_in_pixels.bottom, px(20.0)); // Already in pixels
/// assert_eq!(edges_in_pixels.left, px(32.0)); // 2 rems converted to pixels /// assert_eq!(edges_in_pixels.left, px(32.0)); // 2 rems converted to pixels
/// ``` /// ```
pub fn to_pixels(&self, rem_size: Pixels) -> Edges<Pixels> { pub fn to_pixels(self, rem_size: Pixels) -> Edges<Pixels> {
Edges { Edges {
top: self.top.to_pixels(rem_size), top: self.top.to_pixels(rem_size),
right: self.right.to_pixels(rem_size), right: self.right.to_pixels(rem_size),
@ -2272,7 +2272,7 @@ impl Corners<AbsoluteLength> {
/// assert_eq!(corners_in_pixels.bottom_right, Pixels(30.0)); /// assert_eq!(corners_in_pixels.bottom_right, Pixels(30.0));
/// assert_eq!(corners_in_pixels.bottom_left, Pixels(32.0)); // 2 rems converted to pixels /// assert_eq!(corners_in_pixels.bottom_left, Pixels(32.0)); // 2 rems converted to pixels
/// ``` /// ```
pub fn to_pixels(&self, rem_size: Pixels) -> Corners<Pixels> { pub fn to_pixels(self, rem_size: Pixels) -> Corners<Pixels> {
Corners { Corners {
top_left: self.top_left.to_pixels(rem_size), top_left: self.top_left.to_pixels(rem_size),
top_right: self.top_right.to_pixels(rem_size), top_right: self.top_right.to_pixels(rem_size),
@ -2858,7 +2858,7 @@ impl DevicePixels {
/// let total_bytes = pixels.to_bytes(bytes_per_pixel); /// let total_bytes = pixels.to_bytes(bytes_per_pixel);
/// assert_eq!(total_bytes, 40); // 10 pixels * 4 bytes/pixel = 40 bytes /// assert_eq!(total_bytes, 40); // 10 pixels * 4 bytes/pixel = 40 bytes
/// ``` /// ```
pub fn to_bytes(&self, bytes_per_pixel: u8) -> u32 { pub fn to_bytes(self, bytes_per_pixel: u8) -> u32 {
self.0 as u32 * bytes_per_pixel as u32 self.0 as u32 * bytes_per_pixel as u32
} }
} }
@ -3073,8 +3073,8 @@ pub struct Rems(pub f32);
impl Rems { impl Rems {
/// Convert this Rem value to pixels. /// Convert this Rem value to pixels.
pub fn to_pixels(&self, rem_size: Pixels) -> Pixels { pub fn to_pixels(self, rem_size: Pixels) -> Pixels {
*self * rem_size self * rem_size
} }
} }
@ -3168,9 +3168,9 @@ impl AbsoluteLength {
/// assert_eq!(length_in_pixels.to_pixels(rem_size), Pixels(42.0)); /// assert_eq!(length_in_pixels.to_pixels(rem_size), Pixels(42.0));
/// assert_eq!(length_in_rems.to_pixels(rem_size), Pixels(32.0)); /// assert_eq!(length_in_rems.to_pixels(rem_size), Pixels(32.0));
/// ``` /// ```
pub fn to_pixels(&self, rem_size: Pixels) -> Pixels { pub fn to_pixels(self, rem_size: Pixels) -> Pixels {
match self { match self {
AbsoluteLength::Pixels(pixels) => *pixels, AbsoluteLength::Pixels(pixels) => pixels,
AbsoluteLength::Rems(rems) => rems.to_pixels(rem_size), AbsoluteLength::Rems(rems) => rems.to_pixels(rem_size),
} }
} }
@ -3184,10 +3184,10 @@ impl AbsoluteLength {
/// # Returns /// # Returns
/// ///
/// Returns the `AbsoluteLength` as `Pixels`. /// Returns the `AbsoluteLength` as `Pixels`.
pub fn to_rems(&self, rem_size: Pixels) -> Rems { pub fn to_rems(self, rem_size: Pixels) -> Rems {
match self { match self {
AbsoluteLength::Pixels(pixels) => Rems(pixels.0 / rem_size.0), AbsoluteLength::Pixels(pixels) => Rems(pixels.0 / rem_size.0),
AbsoluteLength::Rems(rems) => *rems, AbsoluteLength::Rems(rems) => rems,
} }
} }
} }
@ -3315,12 +3315,12 @@ impl DefiniteLength {
/// assert_eq!(length_in_rems.to_pixels(base_size, rem_size), Pixels(32.0)); /// assert_eq!(length_in_rems.to_pixels(base_size, rem_size), Pixels(32.0));
/// assert_eq!(length_as_fraction.to_pixels(base_size, rem_size), Pixels(50.0)); /// assert_eq!(length_as_fraction.to_pixels(base_size, rem_size), Pixels(50.0));
/// ``` /// ```
pub fn to_pixels(&self, base_size: AbsoluteLength, rem_size: Pixels) -> Pixels { pub fn to_pixels(self, base_size: AbsoluteLength, rem_size: Pixels) -> Pixels {
match self { match self {
DefiniteLength::Absolute(size) => size.to_pixels(rem_size), DefiniteLength::Absolute(size) => size.to_pixels(rem_size),
DefiniteLength::Fraction(fraction) => match base_size { DefiniteLength::Fraction(fraction) => match base_size {
AbsoluteLength::Pixels(px) => px * *fraction, AbsoluteLength::Pixels(px) => px * fraction,
AbsoluteLength::Rems(rems) => rems * rem_size * *fraction, AbsoluteLength::Rems(rems) => rems * rem_size * fraction,
}, },
} }
} }

View file

@ -172,6 +172,10 @@ pub trait AppContext {
type Result<T>; type Result<T>;
/// Create a new entity in the app context. /// Create a new entity in the app context.
#[expect(
clippy::wrong_self_convention,
reason = "`App::new` is an ubiquitous function for creating entities"
)]
fn new<T: 'static>( fn new<T: 'static>(
&mut self, &mut self,
build_entity: impl FnOnce(&mut Context<T>) -> T, build_entity: impl FnOnce(&mut Context<T>) -> T,

View file

@ -364,29 +364,29 @@ mod tests {
// Ensure `space` results in pending input on the workspace, but not editor // Ensure `space` results in pending input on the workspace, but not editor
let space_workspace = keymap.bindings_for_input(&[space()], &workspace_context()); let space_workspace = keymap.bindings_for_input(&[space()], &workspace_context());
assert!(space_workspace.0.is_empty()); assert!(space_workspace.0.is_empty());
assert_eq!(space_workspace.1, true); assert!(space_workspace.1);
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context()); let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty()); assert!(space_editor.0.is_empty());
assert_eq!(space_editor.1, false); assert!(!space_editor.1);
// Ensure `space w` results in pending input on the workspace, but not editor // Ensure `space w` results in pending input on the workspace, but not editor
let space_w_workspace = keymap.bindings_for_input(&space_w, &workspace_context()); let space_w_workspace = keymap.bindings_for_input(&space_w, &workspace_context());
assert!(space_w_workspace.0.is_empty()); assert!(space_w_workspace.0.is_empty());
assert_eq!(space_w_workspace.1, true); assert!(space_w_workspace.1);
let space_w_editor = keymap.bindings_for_input(&space_w, &editor_workspace_context()); let space_w_editor = keymap.bindings_for_input(&space_w, &editor_workspace_context());
assert!(space_w_editor.0.is_empty()); assert!(space_w_editor.0.is_empty());
assert_eq!(space_w_editor.1, false); assert!(!space_w_editor.1);
// Ensure `space w w` results in the binding in the workspace, but not in the editor // Ensure `space w w` results in the binding in the workspace, but not in the editor
let space_w_w_workspace = keymap.bindings_for_input(&space_w_w, &workspace_context()); let space_w_w_workspace = keymap.bindings_for_input(&space_w_w, &workspace_context());
assert!(!space_w_w_workspace.0.is_empty()); assert!(!space_w_w_workspace.0.is_empty());
assert_eq!(space_w_w_workspace.1, false); assert!(!space_w_w_workspace.1);
let space_w_w_editor = keymap.bindings_for_input(&space_w_w, &editor_workspace_context()); let space_w_w_editor = keymap.bindings_for_input(&space_w_w, &editor_workspace_context());
assert!(space_w_w_editor.0.is_empty()); assert!(space_w_w_editor.0.is_empty());
assert_eq!(space_w_w_editor.1, false); assert!(!space_w_w_editor.1);
// Now test what happens if we have another binding defined AFTER the NoAction // Now test what happens if we have another binding defined AFTER the NoAction
// that should result in pending // that should result in pending
@ -400,7 +400,7 @@ mod tests {
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context()); let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty()); assert!(space_editor.0.is_empty());
assert_eq!(space_editor.1, true); assert!(space_editor.1);
// Now test what happens if we have another binding defined BEFORE the NoAction // Now test what happens if we have another binding defined BEFORE the NoAction
// that should result in pending // that should result in pending
@ -414,7 +414,7 @@ mod tests {
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context()); let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty()); assert!(space_editor.0.is_empty());
assert_eq!(space_editor.1, true); assert!(space_editor.1);
// Now test what happens if we have another binding defined at a higher context // Now test what happens if we have another binding defined at a higher context
// that should result in pending // that should result in pending
@ -428,7 +428,7 @@ mod tests {
let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context()); let space_editor = keymap.bindings_for_input(&[space()], &editor_workspace_context());
assert!(space_editor.0.is_empty()); assert!(space_editor.0.is_empty());
assert_eq!(space_editor.1, true); assert!(space_editor.1);
} }
#[test] #[test]
@ -447,7 +447,7 @@ mod tests {
&[KeyContext::parse("editor").unwrap()], &[KeyContext::parse("editor").unwrap()],
); );
assert!(result.is_empty()); assert!(result.is_empty());
assert_eq!(pending, true); assert!(pending);
let bindings = [ let bindings = [
KeyBinding::new("ctrl-w left", ActionAlpha {}, Some("editor")), KeyBinding::new("ctrl-w left", ActionAlpha {}, Some("editor")),
@ -463,7 +463,7 @@ mod tests {
&[KeyContext::parse("editor").unwrap()], &[KeyContext::parse("editor").unwrap()],
); );
assert_eq!(result.len(), 1); assert_eq!(result.len(), 1);
assert_eq!(pending, false); assert!(!pending);
} }
#[test] #[test]
@ -482,7 +482,7 @@ mod tests {
&[KeyContext::parse("editor").unwrap()], &[KeyContext::parse("editor").unwrap()],
); );
assert!(result.is_empty()); assert!(result.is_empty());
assert_eq!(pending, false); assert!(!pending);
} }
#[test] #[test]
@ -505,7 +505,7 @@ mod tests {
], ],
); );
assert_eq!(result.len(), 1); assert_eq!(result.len(), 1);
assert_eq!(pending, false); assert!(!pending);
} }
#[test] #[test]
@ -527,7 +527,7 @@ mod tests {
], ],
); );
assert_eq!(result.len(), 0); assert_eq!(result.len(), 0);
assert_eq!(pending, false); assert!(!pending);
} }
#[test] #[test]

View file

@ -30,11 +30,8 @@ impl Clone for KeyBinding {
impl KeyBinding { impl KeyBinding {
/// Construct a new keybinding from the given data. Panics on parse error. /// Construct a new keybinding from the given data. Panics on parse error.
pub fn new<A: Action>(keystrokes: &str, action: A, context: Option<&str>) -> Self { pub fn new<A: Action>(keystrokes: &str, action: A, context: Option<&str>) -> Self {
let context_predicate = if let Some(context) = context { let context_predicate =
Some(KeyBindingContextPredicate::parse(context).unwrap().into()) context.map(|context| KeyBindingContextPredicate::parse(context).unwrap().into());
} else {
None
};
Self::load(keystrokes, Box::new(action), context_predicate, None, None).unwrap() Self::load(keystrokes, Box::new(action), context_predicate, None, None).unwrap()
} }

View file

@ -673,7 +673,7 @@ impl PlatformTextSystem for NoopTextSystem {
} }
} }
let mut runs = Vec::default(); let mut runs = Vec::default();
if glyphs.len() > 0 { if !glyphs.is_empty() {
runs.push(ShapedRun { runs.push(ShapedRun {
font_id: FontId(0), font_id: FontId(0),
glyphs, glyphs,

View file

@ -667,7 +667,7 @@ pub(super) const DEFAULT_CURSOR_ICON_NAME: &str = "left_ptr";
impl CursorStyle { impl CursorStyle {
#[cfg(any(feature = "wayland", feature = "x11"))] #[cfg(any(feature = "wayland", feature = "x11"))]
pub(super) fn to_icon_names(&self) -> &'static [&'static str] { pub(super) fn to_icon_names(self) -> &'static [&'static str] {
// Based on cursor names from chromium: // Based on cursor names from chromium:
// https://github.com/chromium/chromium/blob/d3069cf9c973dc3627fa75f64085c6a86c8f41bf/ui/base/cursor/cursor_factory.cc#L113 // https://github.com/chromium/chromium/blob/d3069cf9c973dc3627fa75f64085c6a86c8f41bf/ui/base/cursor/cursor_factory.cc#L113
match self { match self {
@ -990,21 +990,18 @@ mod tests {
#[test] #[test]
fn test_is_within_click_distance() { fn test_is_within_click_distance() {
let zero = Point::new(px(0.0), px(0.0)); let zero = Point::new(px(0.0), px(0.0));
assert_eq!( assert!(is_within_click_distance(zero, Point::new(px(5.0), px(5.0))));
is_within_click_distance(zero, Point::new(px(5.0), px(5.0))), assert!(is_within_click_distance(
true zero,
); Point::new(px(-4.9), px(5.0))
assert_eq!( ));
is_within_click_distance(zero, Point::new(px(-4.9), px(5.0))), assert!(is_within_click_distance(
true Point::new(px(3.0), px(2.0)),
); Point::new(px(-2.0), px(-2.0))
assert_eq!( ));
is_within_click_distance(Point::new(px(3.0), px(2.0)), Point::new(px(-2.0), px(-2.0))), assert!(!is_within_click_distance(
true zero,
); Point::new(px(5.0), px(5.1))
assert_eq!( ),);
is_within_click_distance(zero, Point::new(px(5.0), px(5.1))),
false
);
} }
} }

View file

@ -12,7 +12,7 @@ use wayland_protocols::wp::cursor_shape::v1::client::wp_cursor_shape_device_v1::
use crate::CursorStyle; use crate::CursorStyle;
impl CursorStyle { impl CursorStyle {
pub(super) fn to_shape(&self) -> Shape { pub(super) fn to_shape(self) -> Shape {
match self { match self {
CursorStyle::Arrow => Shape::Default, CursorStyle::Arrow => Shape::Default,
CursorStyle::IBeam => Shape::Text, CursorStyle::IBeam => Shape::Text,

View file

@ -1139,7 +1139,7 @@ fn update_window(mut state: RefMut<WaylandWindowState>) {
} }
impl WindowDecorations { impl WindowDecorations {
fn to_xdg(&self) -> zxdg_toplevel_decoration_v1::Mode { fn to_xdg(self) -> zxdg_toplevel_decoration_v1::Mode {
match self { match self {
WindowDecorations::Client => zxdg_toplevel_decoration_v1::Mode::ClientSide, WindowDecorations::Client => zxdg_toplevel_decoration_v1::Mode::ClientSide,
WindowDecorations::Server => zxdg_toplevel_decoration_v1::Mode::ServerSide, WindowDecorations::Server => zxdg_toplevel_decoration_v1::Mode::ServerSide,
@ -1148,7 +1148,7 @@ impl WindowDecorations {
} }
impl ResizeEdge { impl ResizeEdge {
fn to_xdg(&self) -> xdg_toplevel::ResizeEdge { fn to_xdg(self) -> xdg_toplevel::ResizeEdge {
match self { match self {
ResizeEdge::Top => xdg_toplevel::ResizeEdge::Top, ResizeEdge::Top => xdg_toplevel::ResizeEdge::Top,
ResizeEdge::TopRight => xdg_toplevel::ResizeEdge::TopRight, ResizeEdge::TopRight => xdg_toplevel::ResizeEdge::TopRight,

View file

@ -95,7 +95,7 @@ fn query_render_extent(
} }
impl ResizeEdge { impl ResizeEdge {
fn to_moveresize(&self) -> u32 { fn to_moveresize(self) -> u32 {
match self { match self {
ResizeEdge::TopLeft => 0, ResizeEdge::TopLeft => 0,
ResizeEdge::Top => 1, ResizeEdge::Top => 1,

View file

@ -1090,7 +1090,7 @@ impl PlatformWindow for MacWindow {
NSView::removeFromSuperview(blur_view); NSView::removeFromSuperview(blur_view);
this.blurred_view = None; this.blurred_view = None;
} }
} else if this.blurred_view == None { } else if this.blurred_view.is_none() {
let content_view = this.native_window.contentView(); let content_view = this.native_window.contentView();
let frame = NSView::bounds(content_view); let frame = NSView::bounds(content_view);
let mut blur_view: id = msg_send![BLURRED_VIEW_CLASS, alloc]; let mut blur_view: id = msg_send![BLURRED_VIEW_CLASS, alloc];

View file

@ -45,27 +45,18 @@ impl TabHandles {
}) })
.unwrap_or_default(); .unwrap_or_default();
if let Some(next_handle) = self.handles.get(next_ix) { self.handles.get(next_ix).cloned()
Some(next_handle.clone())
} else {
None
}
} }
pub(crate) fn prev(&self, focused_id: Option<&FocusId>) -> Option<FocusHandle> { pub(crate) fn prev(&self, focused_id: Option<&FocusId>) -> Option<FocusHandle> {
let ix = self.current_index(focused_id).unwrap_or_default(); let ix = self.current_index(focused_id).unwrap_or_default();
let prev_ix; let prev_ix = if ix == 0 {
if ix == 0 { self.handles.len().saturating_sub(1)
prev_ix = self.handles.len().saturating_sub(1);
} else { } else {
prev_ix = ix.saturating_sub(1); ix.saturating_sub(1)
} };
if let Some(prev_handle) = self.handles.get(prev_ix) { self.handles.get(prev_ix).cloned()
Some(prev_handle.clone())
} else {
None
}
} }
} }

View file

@ -49,7 +49,7 @@ impl LanguageName {
pub fn from_proto(s: String) -> Self { pub fn from_proto(s: String) -> Self {
Self(SharedString::from(s)) Self(SharedString::from(s))
} }
pub fn to_proto(self) -> String { pub fn to_proto(&self) -> String {
self.0.to_string() self.0.to_string()
} }
pub fn lsp_id(&self) -> String { pub fn lsp_id(&self) -> String {

View file

@ -19,7 +19,7 @@ impl Role {
} }
} }
pub fn to_proto(&self) -> proto::LanguageModelRole { pub fn to_proto(self) -> proto::LanguageModelRole {
match self { match self {
Role::User => proto::LanguageModelRole::LanguageModelUser, Role::User => proto::LanguageModelRole::LanguageModelUser,
Role::Assistant => proto::LanguageModelRole::LanguageModelAssistant, Role::Assistant => proto::LanguageModelRole::LanguageModelAssistant,

View file

@ -28,7 +28,7 @@ fn migrate(text: &str, patterns: MigrationPatterns, query: &Query) -> Result<Opt
let mut parser = tree_sitter::Parser::new(); let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_json::LANGUAGE.into())?; parser.set_language(&tree_sitter_json::LANGUAGE.into())?;
let syntax_tree = parser let syntax_tree = parser
.parse(&text, None) .parse(text, None)
.context("failed to parse settings")?; .context("failed to parse settings")?;
let mut cursor = tree_sitter::QueryCursor::new(); let mut cursor = tree_sitter::QueryCursor::new();

View file

@ -7149,7 +7149,7 @@ impl ExcerptId {
Self(usize::MAX) Self(usize::MAX)
} }
pub fn to_proto(&self) -> u64 { pub fn to_proto(self) -> u64 {
self.0 as _ self.0 as _
} }

View file

@ -904,7 +904,7 @@ impl BreakpointState {
} }
#[inline] #[inline]
pub fn to_int(&self) -> i32 { pub fn to_int(self) -> i32 {
match self { match self {
BreakpointState::Enabled => 0, BreakpointState::Enabled => 0,
BreakpointState::Disabled => 1, BreakpointState::Disabled => 1,

View file

@ -3,6 +3,7 @@
//! Each byte in memory can either be mapped or unmapped. We try to mimic that twofold: //! Each byte in memory can either be mapped or unmapped. We try to mimic that twofold:
//! - We assume that the memory is divided into pages of a fixed size. //! - We assume that the memory is divided into pages of a fixed size.
//! - We assume that each page can be either mapped or unmapped. //! - We assume that each page can be either mapped or unmapped.
//!
//! These two assumptions drive the shape of the memory representation. //! These two assumptions drive the shape of the memory representation.
//! In particular, we want the unmapped pages to be represented without allocating any memory, as *most* //! In particular, we want the unmapped pages to be represented without allocating any memory, as *most*
//! of the memory in a program space is usually unmapped. //! of the memory in a program space is usually unmapped.
@ -165,8 +166,8 @@ impl Memory {
/// - If it succeeds/fails wholesale, cool; we have no unknown memory regions in this page. /// - If it succeeds/fails wholesale, cool; we have no unknown memory regions in this page.
/// - If it succeeds partially, we know # of mapped bytes. /// - If it succeeds partially, we know # of mapped bytes.
/// We might also know the # of unmapped bytes. /// We might also know the # of unmapped bytes.
/// However, we're still unsure about what's *after* the unreadable region.
/// ///
/// However, we're still unsure about what's *after* the unreadable region.
/// This is where this builder comes in. It lets us track the state of figuring out contents of a single page. /// This is where this builder comes in. It lets us track the state of figuring out contents of a single page.
pub(super) struct MemoryPageBuilder { pub(super) struct MemoryPageBuilder {
chunks: MappedPageContents, chunks: MappedPageContents,

View file

@ -653,7 +653,7 @@ mod tests {
cx.run_until_parked(); cx.run_until_parked();
conflict_set.update(cx, |conflict_set, _| { conflict_set.update(cx, |conflict_set, _| {
assert_eq!(conflict_set.has_conflict, false); assert!(!conflict_set.has_conflict);
assert_eq!(conflict_set.snapshot.conflicts.len(), 0); assert_eq!(conflict_set.snapshot.conflicts.len(), 0);
}); });

View file

@ -199,7 +199,7 @@ pub struct GitEntryRef<'a> {
} }
impl GitEntryRef<'_> { impl GitEntryRef<'_> {
pub fn to_owned(&self) -> GitEntry { pub fn to_owned(self) -> GitEntry {
GitEntry { GitEntry {
entry: self.entry.clone(), entry: self.entry.clone(),
git_summary: self.git_summary, git_summary: self.git_summary,

View file

@ -12691,7 +12691,7 @@ impl DiagnosticSummary {
} }
pub fn to_proto( pub fn to_proto(
&self, self,
language_server_id: LanguageServerId, language_server_id: LanguageServerId,
path: &Path, path: &Path,
) -> proto::DiagnosticSummary { ) -> proto::DiagnosticSummary {

View file

@ -5508,7 +5508,7 @@ mod disable_ai_settings_tests {
project: &[], project: &[],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!(settings.disable_ai, false, "Default should allow AI"); assert!(!settings.disable_ai, "Default should allow AI");
// Test 2: Global true, local false -> still disabled (local cannot re-enable) // Test 2: Global true, local false -> still disabled (local cannot re-enable)
let global_true = Some(true); let global_true = Some(true);
@ -5525,8 +5525,8 @@ mod disable_ai_settings_tests {
project: &[&local_false], project: &[&local_false],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(
settings.disable_ai, true, settings.disable_ai,
"Local false cannot override global true" "Local false cannot override global true"
); );
@ -5545,10 +5545,7 @@ mod disable_ai_settings_tests {
project: &[&local_true], project: &[&local_true],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(settings.disable_ai, "Local true can override global false");
settings.disable_ai, true,
"Local true can override global false"
);
// Test 4: Server can only make more restrictive (set to true) // Test 4: Server can only make more restrictive (set to true)
let user_false = Some(false); let user_false = Some(false);
@ -5565,8 +5562,8 @@ mod disable_ai_settings_tests {
project: &[], project: &[],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(
settings.disable_ai, true, settings.disable_ai,
"Server can set to true even if user is false" "Server can set to true even if user is false"
); );
@ -5585,8 +5582,8 @@ mod disable_ai_settings_tests {
project: &[], project: &[],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(
settings.disable_ai, true, settings.disable_ai,
"Server false cannot override user true" "Server false cannot override user true"
); );
@ -5607,10 +5604,7 @@ mod disable_ai_settings_tests {
project: &[&local_false3, &local_true2, &local_false4], project: &[&local_false3, &local_true2, &local_false4],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(settings.disable_ai, "Any local true should disable AI");
settings.disable_ai, true,
"Any local true should disable AI"
);
// Test 7: All three sources can independently disable AI // Test 7: All three sources can independently disable AI
let user_false2 = Some(false); let user_false2 = Some(false);
@ -5628,8 +5622,8 @@ mod disable_ai_settings_tests {
project: &[&local_true3], project: &[&local_true3],
}; };
let settings = DisableAiSettings::load(sources, cx).unwrap(); let settings = DisableAiSettings::load(sources, cx).unwrap();
assert_eq!( assert!(
settings.disable_ai, true, settings.disable_ai,
"Local can disable even if user and server are false" "Local can disable even if user and server are false"
); );
}); });

View file

@ -4123,7 +4123,7 @@ async fn test_buffer_identity_across_renames(cx: &mut gpui::TestAppContext) {
}) })
.unwrap() .unwrap()
.await .await
.to_included() .into_included()
.unwrap(); .unwrap();
cx.executor().run_until_parked(); cx.executor().run_until_parked();
@ -5918,7 +5918,7 @@ async fn test_create_entry(cx: &mut gpui::TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
// Can't create paths outside the project // Can't create paths outside the project

View file

@ -2515,7 +2515,7 @@ impl ProjectPanel {
if clip_is_cut { if clip_is_cut {
// Convert the clipboard cut entry to a copy entry after the first paste. // Convert the clipboard cut entry to a copy entry after the first paste.
self.clipboard = self.clipboard.take().map(ClipboardEntry::to_copy_entry); self.clipboard = self.clipboard.take().map(ClipboardEntry::into_copy_entry);
} }
self.expand_entry(worktree_id, entry.id, cx); self.expand_entry(worktree_id, entry.id, cx);
@ -5709,7 +5709,7 @@ impl ClipboardEntry {
} }
} }
fn to_copy_entry(self) -> Self { fn into_copy_entry(self) -> Self {
match self { match self {
ClipboardEntry::Copied(_) => self, ClipboardEntry::Copied(_) => self,
ClipboardEntry::Cut(entries) => ClipboardEntry::Copied(entries), ClipboardEntry::Cut(entries) => ClipboardEntry::Copied(entries),

View file

@ -1452,7 +1452,7 @@ impl RemoteConnection for SshRemoteConnection {
.arg(format!( .arg(format!(
"{}:{}", "{}:{}",
self.socket.connection_options.scp_url(), self.socket.connection_options.scp_url(),
dest_path.to_string() dest_path
)) ))
.output(); .output();
@ -1836,11 +1836,7 @@ impl SshRemoteConnection {
})??; })??;
let tmp_path_gz = RemotePathBuf::new( let tmp_path_gz = RemotePathBuf::new(
PathBuf::from(format!( PathBuf::from(format!("{}-download-{}.gz", dst_path, std::process::id())),
"{}-download-{}.gz",
dst_path.to_string(),
std::process::id()
)),
self.ssh_path_style, self.ssh_path_style,
); );
if !self.socket.connection_options.upload_binary_over_ssh if !self.socket.connection_options.upload_binary_over_ssh
@ -2036,7 +2032,7 @@ impl SshRemoteConnection {
.arg(format!( .arg(format!(
"{}:{}", "{}:{}",
self.socket.connection_options.scp_url(), self.socket.connection_options.scp_url(),
dest_path.to_string() dest_path
)) ))
.output() .output()
.await?; .await?;

View file

@ -1207,7 +1207,7 @@ async fn test_remote_rename_entry(cx: &mut TestAppContext, server_cx: &mut TestA
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
cx.run_until_parked(); cx.run_until_parked();

View file

@ -84,7 +84,7 @@ fn init_logging_server(log_file_path: PathBuf) -> Result<Receiver<Vec<u8>>> {
fn flush(&mut self) -> std::io::Result<()> { fn flush(&mut self) -> std::io::Result<()> {
self.channel self.channel
.send_blocking(self.buffer.clone()) .send_blocking(self.buffer.clone())
.map_err(|error| std::io::Error::new(std::io::ErrorKind::Other, error))?; .map_err(std::io::Error::other)?;
self.buffer.clear(); self.buffer.clear();
self.file.flush() self.file.flush()
} }

View file

@ -169,10 +169,7 @@ pub enum KernelStatus {
impl KernelStatus { impl KernelStatus {
pub fn is_connected(&self) -> bool { pub fn is_connected(&self) -> bool {
match self { matches!(self, KernelStatus::Idle | KernelStatus::Busy)
KernelStatus::Idle | KernelStatus::Busy => true,
_ => false,
}
} }
} }

View file

@ -264,7 +264,7 @@ impl http_client::HttpClient for ReqwestClient {
let bytes = response let bytes = response
.bytes_stream() .bytes_stream()
.map_err(|e| futures::io::Error::new(futures::io::ErrorKind::Other, e)) .map_err(futures::io::Error::other)
.into_async_read(); .into_async_read();
let body = http_client::AsyncBody::from_reader(bytes); let body = http_client::AsyncBody::from_reader(bytes);

View file

@ -92,7 +92,7 @@ impl Into<Chunk> for ChunkSlice<'_> {
impl<'a> ChunkSlice<'a> { impl<'a> ChunkSlice<'a> {
#[inline(always)] #[inline(always)]
pub fn is_empty(self) -> bool { pub fn is_empty(&self) -> bool {
self.text.is_empty() self.text.is_empty()
} }

View file

@ -56,7 +56,7 @@ impl Connection {
) { ) {
use anyhow::anyhow; use anyhow::anyhow;
use futures::channel::mpsc; use futures::channel::mpsc;
use std::io::{Error, ErrorKind}; use std::io::Error;
let (tx, rx) = mpsc::unbounded::<WebSocketMessage>(); let (tx, rx) = mpsc::unbounded::<WebSocketMessage>();
@ -71,7 +71,7 @@ impl Connection {
// Writes to a half-open TCP connection will error. // Writes to a half-open TCP connection will error.
if killed.load(SeqCst) { if killed.load(SeqCst) {
std::io::Result::Err(Error::new(ErrorKind::Other, "connection lost"))?; std::io::Result::Err(Error::other("connection lost"))?;
} }
Ok(msg) Ok(msg)

View file

@ -116,8 +116,8 @@ impl SearchOption {
} }
} }
pub fn to_toggle_action(&self) -> &'static dyn Action { pub fn to_toggle_action(self) -> &'static dyn Action {
match *self { match self {
SearchOption::WholeWord => &ToggleWholeWord, SearchOption::WholeWord => &ToggleWholeWord,
SearchOption::CaseSensitive => &ToggleCaseSensitive, SearchOption::CaseSensitive => &ToggleCaseSensitive,
SearchOption::IncludeIgnored => &ToggleIncludeIgnored, SearchOption::IncludeIgnored => &ToggleIncludeIgnored,

View file

@ -50,11 +50,11 @@ impl WorktreeId {
Self(id as usize) Self(id as usize)
} }
pub fn to_proto(&self) -> u64 { pub fn to_proto(self) -> u64 {
self.0 as u64 self.0 as u64
} }
pub fn to_usize(&self) -> usize { pub fn to_usize(self) -> usize {
self.0 self.0
} }
} }

View file

@ -28,7 +28,7 @@ impl ShellKind {
} }
} }
fn to_shell_variable(&self, input: &str) -> String { fn to_shell_variable(self, input: &str) -> String {
match self { match self {
Self::Powershell => Self::to_powershell_variable(input), Self::Powershell => Self::to_powershell_variable(input),
Self::Cmd => Self::to_cmd_variable(input), Self::Cmd => Self::to_cmd_variable(input),

View file

@ -104,7 +104,7 @@ impl SlashCommand for TerminalSlashCommand {
}], }],
run_commands_in_text: false, run_commands_in_text: false,
} }
.to_event_stream())) .into_event_stream()))
} }
} }

View file

@ -2192,7 +2192,7 @@ mod tests {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
(wt, entry) (wt, entry)

View file

@ -582,13 +582,9 @@ impl RenderOnce for ButtonLike {
.when_some(self.width, |this, width| { .when_some(self.width, |this, width| {
this.w(width).justify_center().text_center() this.w(width).justify_center().text_center()
}) })
.when( .when(matches!(self.style, ButtonStyle::Outlined), |this| {
match self.style { this.border_1()
ButtonStyle::Outlined => true, })
_ => false,
},
|this| this.border_1(),
)
.when_some(self.rounding, |this, rounding| match rounding { .when_some(self.rounding, |this, rounding| match rounding {
ButtonLikeRounding::All => this.rounded_sm(), ButtonLikeRounding::All => this.rounded_sm(),
ButtonLikeRounding::Left => this.rounded_l_sm(), ButtonLikeRounding::Left => this.rounded_l_sm(),

View file

@ -13,9 +13,9 @@ impl DateTimeType {
/// ///
/// If the [`DateTimeType`] is already a [`NaiveDateTime`], it will be returned as is. /// If the [`DateTimeType`] is already a [`NaiveDateTime`], it will be returned as is.
/// If the [`DateTimeType`] is a [`DateTime<Local>`], it will be converted to a [`NaiveDateTime`]. /// If the [`DateTimeType`] is a [`DateTime<Local>`], it will be converted to a [`NaiveDateTime`].
pub fn to_naive(&self) -> NaiveDateTime { pub fn to_naive(self) -> NaiveDateTime {
match self { match self {
DateTimeType::Naive(naive) => *naive, DateTimeType::Naive(naive) => naive,
DateTimeType::Local(local) => local.naive_local(), DateTimeType::Local(local) => local.naive_local(),
} }
} }

View file

@ -154,7 +154,7 @@ mod tests {
let mut builder = let mut builder =
ZipEntryBuilder::new(filename.into(), async_zip::Compression::Deflate); ZipEntryBuilder::new(filename.into(), async_zip::Compression::Deflate);
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
let metadata = std::fs::metadata(&path)?; let metadata = std::fs::metadata(path)?;
let perms = metadata.permissions().mode() as u16; let perms = metadata.permissions().mode() as u16;
builder = builder.unix_permissions(perms); builder = builder.unix_permissions(perms);
writer.write_entry_whole(builder, &data).await?; writer.write_entry_whole(builder, &data).await?;

View file

@ -2,6 +2,7 @@ use globset::{Glob, GlobSet, GlobSetBuilder};
use regex::Regex; use regex::Regex;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fmt::{Display, Formatter};
use std::path::StripPrefixError; use std::path::StripPrefixError;
use std::sync::{Arc, OnceLock}; use std::sync::{Arc, OnceLock};
use std::{ use std::{
@ -113,10 +114,6 @@ impl SanitizedPath {
&self.0 &self.0
} }
pub fn to_string(&self) -> String {
self.0.to_string_lossy().to_string()
}
pub fn to_glob_string(&self) -> String { pub fn to_glob_string(&self) -> String {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
{ {
@ -137,6 +134,12 @@ impl SanitizedPath {
} }
} }
impl Display for SanitizedPath {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.0.display())
}
}
impl From<SanitizedPath> for Arc<Path> { impl From<SanitizedPath> for Arc<Path> {
fn from(sanitized_path: SanitizedPath) -> Self { fn from(sanitized_path: SanitizedPath) -> Self {
sanitized_path.0 sanitized_path.0
@ -220,12 +223,8 @@ impl RemotePathBuf {
Self::new(path_buf, style) Self::new(path_buf, style)
} }
pub fn to_string(&self) -> String {
self.string.clone()
}
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]
pub fn to_proto(self) -> String { pub fn to_proto(&self) -> String {
match self.path_style() { match self.path_style() {
PathStyle::Posix => self.to_string(), PathStyle::Posix => self.to_string(),
PathStyle::Windows => self.inner.to_string_lossy().replace('\\', "/"), PathStyle::Windows => self.inner.to_string_lossy().replace('\\', "/"),
@ -233,7 +232,7 @@ impl RemotePathBuf {
} }
#[cfg(not(target_os = "windows"))] #[cfg(not(target_os = "windows"))]
pub fn to_proto(self) -> String { pub fn to_proto(&self) -> String {
match self.path_style() { match self.path_style() {
PathStyle::Posix => self.inner.to_string_lossy().to_string(), PathStyle::Posix => self.inner.to_string_lossy().to_string(),
PathStyle::Windows => self.to_string(), PathStyle::Windows => self.to_string(),
@ -255,6 +254,12 @@ impl RemotePathBuf {
} }
} }
impl Display for RemotePathBuf {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.string)
}
}
/// A delimiter to use in `path_query:row_number:column_number` strings parsing. /// A delimiter to use in `path_query:row_number:column_number` strings parsing.
pub const FILE_ROW_COLUMN_DELIMITER: char = ':'; pub const FILE_ROW_COLUMN_DELIMITER: char = ':';

View file

@ -816,10 +816,7 @@ impl Motion {
} }
fn skip_exclusive_special_case(&self) -> bool { fn skip_exclusive_special_case(&self) -> bool {
match self { matches!(self, Motion::WrappingLeft | Motion::WrappingRight)
Motion::WrappingLeft | Motion::WrappingRight => true,
_ => false,
}
} }
pub(crate) fn push_to_jump_list(&self) -> bool { pub(crate) fn push_to_jump_list(&self) -> bool {
@ -4099,7 +4096,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇhe quick brown fox ˇhe quick brown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick bˇrown fox the quick bˇrown fox
@ -4109,7 +4106,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇown fox ˇown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick brown foˇx the quick brown foˇx
@ -4119,7 +4116,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇ ˇ
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
} }
#[gpui::test] #[gpui::test]
@ -4134,7 +4131,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇbrown fox ˇbrown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick bˇrown fox the quick bˇrown fox
@ -4144,7 +4141,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
the quickˇown fox the quickˇown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick brown foˇx the quick brown foˇx
@ -4154,7 +4151,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
the quicˇk the quicˇk
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
ˇthe quick brown fox ˇthe quick brown fox
@ -4164,7 +4161,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇ fox ˇ fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
ˇthe quick brown fox ˇthe quick brown fox
@ -4174,7 +4171,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇuick brown fox ˇuick brown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
} }
#[gpui::test] #[gpui::test]
@ -4189,7 +4186,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
the quick brown foˇx the quick brown foˇx
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
ˇthe quick brown fox ˇthe quick brown fox
@ -4199,7 +4196,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇx ˇx
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
} }
#[gpui::test] #[gpui::test]
@ -4215,7 +4212,7 @@ mod test {
the quick brown fox the quick brown fox
ˇthe quick brown fox ˇthe quick brown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick bˇrown fox the quick bˇrown fox
@ -4226,7 +4223,7 @@ mod test {
the quick brˇrown fox the quick brˇrown fox
jumped overown fox jumped overown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick brown foˇx the quick brown foˇx
@ -4237,7 +4234,7 @@ mod test {
the quick brown foxˇx the quick brown foxˇx
jumped over the la jumped over the la
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick brown fox the quick brown fox
@ -4248,7 +4245,7 @@ mod test {
thˇhe quick brown fox thˇhe quick brown fox
je quick brown fox je quick brown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
} }
#[gpui::test] #[gpui::test]
@ -4263,7 +4260,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
ˇe quick brown fox ˇe quick brown fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick bˇrown fox the quick bˇrown fox
@ -4273,7 +4270,7 @@ mod test {
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
the quick bˇn fox the quick bˇn fox
jumped over the lazy dog"}); jumped over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
cx.set_shared_state(indoc! {" cx.set_shared_state(indoc! {"
the quick brown foˇx the quick brown foˇx
@ -4282,6 +4279,6 @@ mod test {
cx.simulate_shared_keystrokes("d v e").await; cx.simulate_shared_keystrokes("d v e").await;
cx.shared_state().await.assert_eq(indoc! {" cx.shared_state().await.assert_eq(indoc! {"
the quick brown foˇd over the lazy dog"}); the quick brown foˇd over the lazy dog"});
assert_eq!(cx.cx.forced_motion(), false); assert!(!cx.cx.forced_motion());
} }
} }

View file

@ -1734,10 +1734,7 @@ impl Vim {
editor.set_autoindent(vim.should_autoindent()); editor.set_autoindent(vim.should_autoindent());
editor.selections.line_mode = matches!(vim.mode, Mode::VisualLine); editor.selections.line_mode = matches!(vim.mode, Mode::VisualLine);
let hide_edit_predictions = match vim.mode { let hide_edit_predictions = !matches!(vim.mode, Mode::Insert | Mode::Replace);
Mode::Insert | Mode::Replace => false,
_ => true,
};
editor.set_edit_predictions_hidden_for_vim_mode(hide_edit_predictions, window, cx); editor.set_edit_predictions_hidden_for_vim_mode(hide_edit_predictions, window, cx);
}); });
cx.notify() cx.notify()

View file

@ -5509,7 +5509,7 @@ impl ProjectEntryId {
Self(id as usize) Self(id as usize)
} }
pub fn to_proto(&self) -> u64 { pub fn to_proto(self) -> u64 {
self.0 as u64 self.0 as u64
} }
@ -5517,14 +5517,14 @@ impl ProjectEntryId {
ProjectEntryId(id) ProjectEntryId(id)
} }
pub fn to_usize(&self) -> usize { pub fn to_usize(self) -> usize {
self.0 self.0
} }
} }
#[cfg(any(test, feature = "test-support"))] #[cfg(any(test, feature = "test-support"))]
impl CreatedEntry { impl CreatedEntry {
pub fn to_included(self) -> Option<Entry> { pub fn into_included(self) -> Option<Entry> {
match self { match self {
CreatedEntry::Included(entry) => Some(entry), CreatedEntry::Included(entry) => Some(entry),
CreatedEntry::Excluded { .. } => None, CreatedEntry::Excluded { .. } => None,

View file

@ -1274,7 +1274,7 @@ async fn test_create_directory_during_initial_scan(cx: &mut TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
assert!(entry.is_dir()); assert!(entry.is_dir());
@ -1323,7 +1323,7 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
assert!(entry.is_file()); assert!(entry.is_file());
@ -1357,7 +1357,7 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
assert!(entry.is_file()); assert!(entry.is_file());
@ -1377,7 +1377,7 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
assert!(entry.is_file()); assert!(entry.is_file());
@ -1395,7 +1395,7 @@ async fn test_create_dir_all_on_create_entry(cx: &mut TestAppContext) {
}) })
.await .await
.unwrap() .unwrap()
.to_included() .into_included()
.unwrap(); .unwrap();
assert!(entry.is_file()); assert!(entry.is_file());
@ -1726,7 +1726,7 @@ fn randomly_mutate_worktree(
); );
let task = worktree.rename_entry(entry.id, new_path, cx); let task = worktree.rename_entry(entry.id, new_path, cx);
cx.background_spawn(async move { cx.background_spawn(async move {
task.await?.to_included().unwrap(); task.await?.into_included().unwrap();
Ok(()) Ok(())
}) })
} }

View file

@ -122,9 +122,6 @@ impl Model {
} }
pub fn supports_images(&self) -> bool { pub fn supports_images(&self) -> bool {
match self { matches!(self, Self::Grok2Vision)
Self::Grok2Vision => true,
_ => false,
}
} }
} }