Another batch of lint fixes (#36521)

- **Enable a bunch of extra lints**
- **First batch of fixes**
- **More fixes**

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 22:33:44 +02:00 committed by GitHub
parent 69b1c6d6f5
commit 6825715503
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
147 changed files with 788 additions and 1042 deletions

View file

@ -822,14 +822,20 @@ style = { level = "allow", priority = -1 }
# Temporary list of style lints that we've fixed so far.
comparison_to_empty = "warn"
into_iter_on_ref = "warn"
iter_cloned_collect = "warn"
iter_next_slice = "warn"
iter_nth = "warn"
iter_nth_zero = "warn"
iter_skip_next = "warn"
let_and_return = "warn"
module_inception = { level = "deny" }
question_mark = { level = "deny" }
single_match = "warn"
redundant_closure = { level = "deny" }
redundant_static_lifetimes = { level = "warn" }
redundant_pattern_matching = "warn"
redundant_field_names = "warn"
declare_interior_mutable_const = { level = "deny" }
collapsible_if = { level = "warn"}
collapsible_else_if = { level = "warn" }
@ -857,6 +863,10 @@ too_many_arguments = "allow"
# We often have large enum variants yet we rarely actually bother with splitting them up.
large_enum_variant = "allow"
# `enum_variant_names` fires for all enums, even when they derive serde traits.
# Adhering to this lint would be a breaking change.
enum_variant_names = "allow"
[workspace.metadata.cargo-machete]
ignored = [
"bindgen",

View file

@ -264,15 +264,14 @@ impl ActionLog {
if let Some((git_diff, (buffer_repo, _))) = git_diff.as_ref().zip(buffer_repo) {
cx.update(|cx| {
let mut old_head = buffer_repo.read(cx).head_commit.clone();
Some(cx.subscribe(git_diff, move |_, event, cx| match event {
buffer_diff::BufferDiffEvent::DiffChanged { .. } => {
Some(cx.subscribe(git_diff, move |_, event, cx| {
if let buffer_diff::BufferDiffEvent::DiffChanged { .. } = event {
let new_head = buffer_repo.read(cx).head_commit.clone();
if new_head != old_head {
old_head = new_head;
git_diff_updates_tx.send(()).ok();
}
}
_ => {}
}))
})?
} else {

View file

@ -103,26 +103,21 @@ impl ActivityIndicator {
cx.subscribe_in(
&workspace_handle,
window,
|activity_indicator, _, event, window, cx| match event {
workspace::Event::ClearActivityIndicator { .. } => {
if activity_indicator.statuses.pop().is_some() {
activity_indicator.dismiss_error_message(
&DismissErrorMessage,
window,
cx,
);
|activity_indicator, _, event, window, cx| {
if let workspace::Event::ClearActivityIndicator { .. } = event
&& activity_indicator.statuses.pop().is_some()
{
activity_indicator.dismiss_error_message(&DismissErrorMessage, window, cx);
cx.notify();
}
}
_ => {}
},
)
.detach();
cx.subscribe(
&project.read(cx).lsp_store(),
|activity_indicator, _, event, cx| match event {
LspStoreEvent::LanguageServerUpdate { name, message, .. } => {
|activity_indicator, _, event, cx| {
if let LspStoreEvent::LanguageServerUpdate { name, message, .. } = event {
if let proto::update_language_server::Variant::StatusUpdate(status_update) =
message
{
@ -191,7 +186,6 @@ impl ActivityIndicator {
}
cx.notify()
}
_ => {}
},
)
.detach();
@ -206,9 +200,10 @@ impl ActivityIndicator {
cx.subscribe(
&project.read(cx).git_store().clone(),
|_, _, event: &GitStoreEvent, cx| match event {
project::git_store::GitStoreEvent::JobsUpdated => cx.notify(),
_ => {}
|_, _, event: &GitStoreEvent, cx| {
if let project::git_store::GitStoreEvent::JobsUpdated = event {
cx.notify()
}
},
)
.detach();

View file

@ -1645,15 +1645,13 @@ impl Thread {
self.tool_use
.request_tool_use(tool_message_id, tool_use, tool_use_metadata.clone(), cx);
let pending_tool_use = self.tool_use.insert_tool_output(
self.tool_use.insert_tool_output(
tool_use_id.clone(),
tool_name,
tool_output,
self.configured_model.as_ref(),
self.completion_mode,
);
pending_tool_use
)
}
pub fn stream_completion(

View file

@ -74,7 +74,7 @@ impl Column for DataType {
}
}
const RULES_FILE_NAMES: [&'static str; 9] = [
const RULES_FILE_NAMES: [&str; 9] = [
".rules",
".cursorrules",
".windsurfrules",

View file

@ -28,7 +28,7 @@ use std::rc::Rc;
use std::sync::Arc;
use util::ResultExt;
const RULES_FILE_NAMES: [&'static str; 9] = [
const RULES_FILE_NAMES: [&str; 9] = [
".rules",
".cursorrules",
".windsurfrules",

View file

@ -655,8 +655,7 @@ mod tests {
mode: mode.clone(),
};
let result = cx.update(|cx| resolve_path(&input, project, cx));
result
cx.update(|cx| resolve_path(&input, project, cx))
}
fn assert_resolved_path_eq(path: anyhow::Result<ProjectPath>, expected: &str) {

View file

@ -149,7 +149,7 @@ impl acp_old::Client for OldAcpClientDelegate {
Ok(acp_old::RequestToolCallConfirmationResponse {
id: acp_old::ToolCallId(old_acp_id),
outcome: outcome,
outcome,
})
}
@ -266,7 +266,7 @@ impl acp_old::Client for OldAcpClientDelegate {
fn into_new_tool_call(id: acp::ToolCallId, request: acp_old::PushToolCallParams) -> acp::ToolCall {
acp::ToolCall {
id: id,
id,
title: request.label,
kind: acp_kind_from_old_icon(request.icon),
status: acp::ToolCallStatus::InProgress,

View file

@ -175,9 +175,9 @@ impl McpServerTool for PermissionTool {
let claude_tool = ClaudeTool::infer(&input.tool_name, input.input.clone());
let tool_call_id = acp::ToolCallId(input.tool_use_id.context("Tool ID required")?.into());
const ALWAYS_ALLOW: &'static str = "always_allow";
const ALLOW: &'static str = "allow";
const REJECT: &'static str = "reject";
const ALWAYS_ALLOW: &str = "always_allow";
const ALLOW: &str = "allow";
const REJECT: &str = "reject";
let chosen_option = thread
.update(cx, |thread, cx| {

View file

@ -428,12 +428,9 @@ pub async fn new_test_thread(
.await
.unwrap();
let thread = cx
.update(|cx| connection.new_thread(project.clone(), current_dir.as_ref(), cx))
cx.update(|cx| connection.new_thread(project.clone(), current_dir.as_ref(), cx))
.await
.unwrap();
thread
.unwrap()
}
pub async fn run_until_first_tool_call(

View file

@ -134,8 +134,8 @@ impl MessageEditor {
if prevent_slash_commands {
subscriptions.push(cx.subscribe_in(&editor, window, {
let semantics_provider = semantics_provider.clone();
move |this, editor, event, window, cx| match event {
EditorEvent::Edited { .. } => {
move |this, editor, event, window, cx| {
if let EditorEvent::Edited { .. } = event {
this.highlight_slash_command(
semantics_provider.clone(),
editor.clone(),
@ -143,7 +143,6 @@ impl MessageEditor {
cx,
);
}
_ => {}
}
}));
}

View file

@ -2124,7 +2124,7 @@ impl AcpThreadView {
.map(|view| div().px_4().w_full().max_w_128().child(view)),
)
.child(h_flex().mt_1p5().justify_center().children(
connection.auth_methods().into_iter().map(|method| {
connection.auth_methods().iter().map(|method| {
Button::new(SharedString::from(method.id.0.clone()), method.name.clone())
.on_click({
let method_id = method.id.clone();
@ -2574,7 +2574,7 @@ impl AcpThreadView {
) -> Div {
let editor_bg_color = cx.theme().colors().editor_background;
v_flex().children(changed_buffers.into_iter().enumerate().flat_map(
v_flex().children(changed_buffers.iter().enumerate().flat_map(
|(index, (buffer, _diff))| {
let file = buffer.read(cx).file()?;
let path = file.path();

View file

@ -1373,11 +1373,11 @@ impl ActiveThread {
editor.focus_handle(cx).focus(window);
editor.move_to_end(&editor::actions::MoveToEnd, window, cx);
});
let buffer_edited_subscription = cx.subscribe(&editor, |this, _, event, cx| match event {
EditorEvent::BufferEdited => {
let buffer_edited_subscription =
cx.subscribe(&editor, |this, _, event: &EditorEvent, cx| {
if event == &EditorEvent::BufferEdited {
this.update_editing_message_token_count(true, cx);
}
_ => {}
});
let context_picker_menu_handle = PopoverMenuHandle::default();

View file

@ -958,7 +958,7 @@ impl AgentConfiguration {
}
parent.child(v_flex().py_1p5().px_1().gap_1().children(
tools.into_iter().enumerate().map(|(ix, tool)| {
tools.iter().enumerate().map(|(ix, tool)| {
h_flex()
.id(("tool-item", ix))
.px_1()

View file

@ -487,7 +487,7 @@ impl ConfigureContextServerModal {
}
fn render_modal_description(&self, window: &mut Window, cx: &mut Context<Self>) -> AnyElement {
const MODAL_DESCRIPTION: &'static str = "Visit the MCP server configuration docs to find all necessary arguments and environment variables.";
const MODAL_DESCRIPTION: &str = "Visit the MCP server configuration docs to find all necessary arguments and environment variables.";
if let ConfigurationSource::Extension {
installation_instructions: Some(installation_instructions),

View file

@ -322,16 +322,14 @@ impl AgentDiffPane {
}
fn handle_native_thread_event(&mut self, event: &ThreadEvent, cx: &mut Context<Self>) {
match event {
ThreadEvent::SummaryGenerated => self.update_title(cx),
_ => {}
if let ThreadEvent::SummaryGenerated = event {
self.update_title(cx)
}
}
fn handle_acp_thread_event(&mut self, event: &AcpThreadEvent, cx: &mut Context<Self>) {
match event {
AcpThreadEvent::TitleUpdated => self.update_title(cx),
_ => {}
if let AcpThreadEvent::TitleUpdated = event {
self.update_title(cx)
}
}
@ -1541,17 +1539,13 @@ impl AgentDiff {
window: &mut Window,
cx: &mut Context<Self>,
) {
match event {
workspace::Event::ItemAdded { item } => {
if let Some(editor) = item.downcast::<Editor>()
if let workspace::Event::ItemAdded { item } = event
&& let Some(editor) = item.downcast::<Editor>()
&& let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx)
{
self.register_editor(workspace.downgrade(), buffer.clone(), editor, window, cx);
}
}
_ => {}
}
}
fn full_editor_buffer(editor: &Editor, cx: &App) -> Option<WeakEntity<Buffer>> {
if editor.mode().is_full() {

View file

@ -354,7 +354,7 @@ impl ActiveView {
Self::Thread {
change_title_editor: editor,
thread: active_thread,
message_editor: message_editor,
message_editor,
_subscriptions: subscriptions,
}
}
@ -756,23 +756,23 @@ impl AgentPanel {
.ok();
});
let _default_model_subscription = cx.subscribe(
let _default_model_subscription =
cx.subscribe(
&LanguageModelRegistry::global(cx),
|this, _, event: &language_model::Event, cx| match event {
language_model::Event::DefaultModelChanged => match &this.active_view {
|this, _, event: &language_model::Event, cx| {
if let language_model::Event::DefaultModelChanged = event {
match &this.active_view {
ActiveView::Thread { thread, .. } => {
thread
.read(cx)
.thread()
.clone()
.update(cx, |thread, cx| thread.get_or_init_configured_model(cx));
thread.read(cx).thread().clone().update(cx, |thread, cx| {
thread.get_or_init_configured_model(cx)
});
}
ActiveView::ExternalAgentThread { .. }
| ActiveView::TextThread { .. }
| ActiveView::History
| ActiveView::Configuration => {}
},
_ => {}
}
}
},
);
@ -1589,8 +1589,7 @@ impl AgentPanel {
let current_is_special = current_is_history || current_is_config;
let new_is_special = new_is_history || new_is_config;
match &self.active_view {
ActiveView::Thread { thread, .. } => {
if let ActiveView::Thread { thread, .. } = &self.active_view {
let thread = thread.read(cx);
if thread.is_empty() {
let id = thread.thread().read(cx).id().clone();
@ -1599,8 +1598,6 @@ impl AgentPanel {
});
}
}
_ => {}
}
match &new_view {
ActiveView::Thread { thread, .. } => self.history_store.update(cx, |store, cx| {
@ -3465,7 +3462,7 @@ impl AgentPanel {
.on_drop(cx.listener(move |this, paths: &ExternalPaths, window, cx| {
let tasks = paths
.paths()
.into_iter()
.iter()
.map(|path| {
Workspace::project_path_for_path(this.project.clone(), path, false, cx)
})

View file

@ -385,12 +385,11 @@ impl ContextPicker {
}
pub fn select_first(&mut self, window: &mut Window, cx: &mut Context<Self>) {
match &self.mode {
ContextPickerState::Default(entity) => entity.update(cx, |entity, cx| {
entity.select_first(&Default::default(), window, cx)
}),
// Other variants already select their first entry on open automatically
_ => {}
if let ContextPickerState::Default(entity) = &self.mode {
entity.update(cx, |entity, cx| {
entity.select_first(&Default::default(), window, cx)
})
}
}

View file

@ -117,7 +117,7 @@ pub(crate) fn create_editor(
let mut editor = Editor::new(
editor::EditorMode::AutoHeight {
min_lines,
max_lines: max_lines,
max_lines,
},
buffer,
None,
@ -215,9 +215,10 @@ impl MessageEditor {
let subscriptions = vec![
cx.subscribe_in(&context_strip, window, Self::handle_context_strip_event),
cx.subscribe(&editor, |this, _, event, cx| match event {
EditorEvent::BufferEdited => this.handle_message_changed(cx),
_ => {}
cx.subscribe(&editor, |this, _, event: &EditorEvent, cx| {
if event == &EditorEvent::BufferEdited {
this.handle_message_changed(cx)
}
}),
cx.observe(&context_store, |this, _, cx| {
// When context changes, reload it for token counting.
@ -1132,7 +1133,7 @@ impl MessageEditor {
)
.when(is_edit_changes_expanded, |parent| {
parent.child(
v_flex().children(changed_buffers.into_iter().enumerate().flat_map(
v_flex().children(changed_buffers.iter().enumerate().flat_map(
|(index, (buffer, _diff))| {
let file = buffer.read(cx).file()?;
let path = file.path();
@ -1605,7 +1606,8 @@ pub fn extract_message_creases(
.collect::<HashMap<_, _>>();
// Filter the addon's list of creases based on what the editor reports,
// since the addon might have removed creases in it.
let creases = editor.display_map.update(cx, |display_map, cx| {
editor.display_map.update(cx, |display_map, cx| {
display_map
.snapshot(cx)
.crease_snapshot
@ -1629,8 +1631,7 @@ pub fn extract_message_creases(
}
})
.collect()
});
creases
})
}
impl EventEmitter<MessageEditorEvent> for MessageEditor {}

View file

@ -327,9 +327,7 @@ where
};
let picker_view = cx.new(|cx| {
let picker =
Picker::uniform_list(delegate, window, cx).max_height(Some(rems(20.).into()));
picker
Picker::uniform_list(delegate, window, cx).max_height(Some(rems(20.).into()))
});
let handle = self

View file

@ -540,7 +540,7 @@ impl TextThreadEditor {
let context = self.context.read(cx);
let sections = context
.slash_command_output_sections()
.into_iter()
.iter()
.filter(|section| section.is_valid(context.buffer().read(cx)))
.cloned()
.collect::<Vec<_>>();
@ -1237,7 +1237,7 @@ impl TextThreadEditor {
let mut new_blocks = vec![];
let mut block_index_to_message = vec![];
for message in self.context.read(cx).messages(cx) {
if let Some(_) = blocks_to_remove.remove(&message.id) {
if blocks_to_remove.remove(&message.id).is_some() {
// This is an old message that we might modify.
let Some((meta, block_id)) = old_blocks.get_mut(&message.id) else {
debug_assert!(
@ -1275,7 +1275,7 @@ impl TextThreadEditor {
context_editor_view: &Entity<TextThreadEditor>,
cx: &mut Context<Workspace>,
) -> Option<(String, bool)> {
const CODE_FENCE_DELIMITER: &'static str = "```";
const CODE_FENCE_DELIMITER: &str = "```";
let context_editor = context_editor_view.read(cx).editor.clone();
context_editor.update(cx, |context_editor, cx| {
@ -2161,8 +2161,8 @@ impl TextThreadEditor {
/// Returns the contents of the *outermost* fenced code block that contains the given offset.
fn find_surrounding_code_block(snapshot: &BufferSnapshot, offset: usize) -> Option<Range<usize>> {
const CODE_BLOCK_NODE: &'static str = "fenced_code_block";
const CODE_BLOCK_CONTENT: &'static str = "code_fence_content";
const CODE_BLOCK_NODE: &str = "fenced_code_block";
const CODE_BLOCK_CONTENT: &str = "code_fence_content";
let layer = snapshot.syntax_layers().next()?;
@ -3129,7 +3129,7 @@ mod tests {
let context_editor = window
.update(&mut cx, |_, window, cx| {
cx.new(|cx| {
let editor = TextThreadEditor::for_context(
TextThreadEditor::for_context(
context.clone(),
fs,
workspace.downgrade(),
@ -3137,8 +3137,7 @@ mod tests {
None,
window,
cx,
);
editor
)
})
})
.unwrap();

View file

@ -14,12 +14,10 @@ pub struct IncompatibleToolsState {
impl IncompatibleToolsState {
pub fn new(thread: Entity<Thread>, cx: &mut Context<Self>) -> Self {
let _tool_working_set_subscription =
cx.subscribe(&thread, |this, _, event, _| match event {
ThreadEvent::ProfileChanged => {
let _tool_working_set_subscription = cx.subscribe(&thread, |this, _, event, _| {
if let ThreadEvent::ProfileChanged = event {
this.cache.clear();
}
_ => {}
});
Self {

View file

@ -590,7 +590,7 @@ impl From<&Message> for MessageMetadata {
impl MessageMetadata {
pub fn is_cache_valid(&self, buffer: &BufferSnapshot, range: &Range<usize>) -> bool {
let result = match &self.cache {
match &self.cache {
Some(MessageCacheMetadata { cached_at, .. }) => !buffer.has_edits_since_in_range(
cached_at,
Range {
@ -599,8 +599,7 @@ impl MessageMetadata {
},
),
_ => false,
};
result
}
}
}
@ -2081,16 +2080,13 @@ impl AssistantContext {
match event {
LanguageModelCompletionEvent::StatusUpdate(status_update) => {
match status_update {
CompletionRequestStatus::UsageUpdated { amount, limit } => {
if let CompletionRequestStatus::UsageUpdated { amount, limit } = status_update {
this.update_model_request_usage(
amount as u32,
limit,
cx,
);
}
_ => {}
}
}
LanguageModelCompletionEvent::StartMessage { .. } => {}
LanguageModelCompletionEvent::Stop(reason) => {

View file

@ -223,7 +223,7 @@ fn collect_files(
cx: &mut App,
) -> impl Stream<Item = Result<SlashCommandEvent>> + use<> {
let Ok(matchers) = glob_inputs
.into_iter()
.iter()
.map(|glob_input| {
custom_path_matcher::PathMatcher::new(&[glob_input.to_owned()])
.with_context(|| format!("invalid path {glob_input}"))
@ -379,7 +379,7 @@ fn collect_files(
}
}
while let Some(_) = directory_stack.pop() {
while directory_stack.pop().is_some() {
events_tx.unbounded_send(Ok(SlashCommandEvent::EndSection))?;
}
}
@ -491,7 +491,7 @@ mod custom_path_matcher {
impl PathMatcher {
pub fn new(globs: &[String]) -> Result<Self, globset::Error> {
let globs = globs
.into_iter()
.iter()
.map(|glob| Glob::new(&SanitizedPath::from(glob).to_glob_string()))
.collect::<Result<Vec<_>, _>>()?;
let sources = globs.iter().map(|glob| glob.glob().to_owned()).collect();

View file

@ -156,13 +156,13 @@ fn resolve_context_server_tool_name_conflicts(
if duplicated_tool_names.is_empty() {
return context_server_tools
.into_iter()
.iter()
.map(|tool| (resolve_tool_name(tool).into(), tool.clone()))
.collect();
}
context_server_tools
.into_iter()
.iter()
.filter_map(|tool| {
let mut tool_name = resolve_tool_name(tool);
if !duplicated_tool_names.contains(&tool_name) {

View file

@ -72,11 +72,10 @@ pub fn init(http_client: Arc<HttpClientWithUrl>, cx: &mut App) {
register_web_search_tool(&LanguageModelRegistry::global(cx), cx);
cx.subscribe(
&LanguageModelRegistry::global(cx),
move |registry, event, cx| match event {
language_model::Event::DefaultModelChanged => {
move |registry, event, cx| {
if let language_model::Event::DefaultModelChanged = event {
register_web_search_tool(&registry, cx);
}
_ => {}
},
)
.detach();

View file

@ -1356,8 +1356,7 @@ mod tests {
mode: mode.clone(),
};
let result = cx.update(|cx| resolve_path(&input, project, cx));
result
cx.update(|cx| resolve_path(&input, project, cx))
}
fn assert_resolved_path_eq(path: anyhow::Result<ProjectPath>, expected: &str) {

View file

@ -216,7 +216,8 @@ impl Tool for TerminalTool {
async move |cx| {
let program = program.await;
let env = env.await;
let terminal = project
project
.update(cx, |project, cx| {
project.create_terminal(
TerminalKind::Task(task::SpawnInTerminal {
@ -229,8 +230,7 @@ impl Tool for TerminalTool {
cx,
)
})?
.await;
terminal
.await
}
});

View file

@ -494,11 +494,11 @@ mod linux {
Ok(Fork::Parent(_)) => Ok(()),
Ok(Fork::Child) => {
unsafe { std::env::set_var(FORCE_CLI_MODE_ENV_VAR_NAME, "") };
if let Err(_) = fork::setsid() {
if fork::setsid().is_err() {
eprintln!("failed to setsid: {}", std::io::Error::last_os_error());
process::exit(1);
}
if let Err(_) = fork::close_fd() {
if fork::close_fd().is_err() {
eprintln!("failed to close_fd: {}", std::io::Error::last_os_error());
}
let error =
@ -534,8 +534,8 @@ mod flatpak {
use std::process::Command;
use std::{env, process};
const EXTRA_LIB_ENV_NAME: &'static str = "ZED_FLATPAK_LIB_PATH";
const NO_ESCAPE_ENV_NAME: &'static str = "ZED_FLATPAK_NO_ESCAPE";
const EXTRA_LIB_ENV_NAME: &str = "ZED_FLATPAK_LIB_PATH";
const NO_ESCAPE_ENV_NAME: &str = "ZED_FLATPAK_NO_ESCAPE";
/// Adds bundled libraries to LD_LIBRARY_PATH if running under flatpak
pub fn ld_extra_libs() {

View file

@ -4970,7 +4970,7 @@ async fn test_references(
"Rust",
FakeLspAdapter {
name: "my-fake-lsp-adapter",
capabilities: capabilities,
capabilities,
..FakeLspAdapter::default()
},
);

View file

@ -397,11 +397,10 @@ impl MessageEditor {
) -> Option<(Anchor, String, &'static [StringMatchCandidate])> {
static EMOJI_FUZZY_MATCH_CANDIDATES: LazyLock<Vec<StringMatchCandidate>> =
LazyLock::new(|| {
let emojis = emojis::iter()
emojis::iter()
.flat_map(|s| s.shortcodes())
.map(|emoji| StringMatchCandidate::new(0, emoji))
.collect::<Vec<_>>();
emojis
.collect::<Vec<_>>()
});
let end_offset = end_anchor.to_offset(buffer.read(cx));

View file

@ -77,7 +77,7 @@ impl McpServer {
socket_path,
_server_task: server_task,
tools,
handlers: handlers,
handlers,
})
})
}

View file

@ -238,7 +238,7 @@ impl PythonDebugAdapter {
return Err("Failed to create base virtual environment".into());
}
const DIR: &'static str = if cfg!(target_os = "windows") {
const DIR: &str = if cfg!(target_os = "windows") {
"Scripts"
} else {
"bin"

View file

@ -257,7 +257,7 @@ impl DebugPanel {
.as_ref()
.map(|entity| entity.downgrade()),
task_context: task_context.clone(),
worktree_id: worktree_id,
worktree_id,
});
};
running.resolve_scenario(

View file

@ -87,7 +87,7 @@ impl DebugSession {
self.stack_trace_view.get_or_init(|| {
let stackframe_list = running_state.read(cx).stack_frame_list().clone();
let stack_frame_view = cx.new(|cx| {
cx.new(|cx| {
StackTraceView::new(
workspace.clone(),
project.clone(),
@ -95,9 +95,7 @@ impl DebugSession {
window,
cx,
)
});
stack_frame_view
})
})
}

View file

@ -358,7 +358,7 @@ pub(crate) fn new_debugger_pane(
}
};
let ret = cx.new(move |cx| {
cx.new(move |cx| {
let mut pane = Pane::new(
workspace.clone(),
project.clone(),
@ -562,9 +562,7 @@ pub(crate) fn new_debugger_pane(
}
});
pane
});
ret
})
}
pub struct DebugTerminal {

View file

@ -329,8 +329,8 @@ impl BreakpointList {
let text = self.input.read(cx).text(cx);
match mode {
ActiveBreakpointStripMode::Log => match &entry.kind {
BreakpointEntryKind::LineBreakpoint(line_breakpoint) => {
ActiveBreakpointStripMode::Log => {
if let BreakpointEntryKind::LineBreakpoint(line_breakpoint) = &entry.kind {
Self::edit_line_breakpoint_inner(
&self.breakpoint_store,
line_breakpoint.breakpoint.path.clone(),
@ -339,10 +339,9 @@ impl BreakpointList {
cx,
);
}
_ => {}
},
ActiveBreakpointStripMode::Condition => match &entry.kind {
BreakpointEntryKind::LineBreakpoint(line_breakpoint) => {
}
ActiveBreakpointStripMode::Condition => {
if let BreakpointEntryKind::LineBreakpoint(line_breakpoint) = &entry.kind {
Self::edit_line_breakpoint_inner(
&self.breakpoint_store,
line_breakpoint.breakpoint.path.clone(),
@ -351,10 +350,9 @@ impl BreakpointList {
cx,
);
}
_ => {}
},
ActiveBreakpointStripMode::HitCondition => match &entry.kind {
BreakpointEntryKind::LineBreakpoint(line_breakpoint) => {
}
ActiveBreakpointStripMode::HitCondition => {
if let BreakpointEntryKind::LineBreakpoint(line_breakpoint) = &entry.kind {
Self::edit_line_breakpoint_inner(
&self.breakpoint_store,
line_breakpoint.breakpoint.path.clone(),
@ -363,8 +361,7 @@ impl BreakpointList {
cx,
);
}
_ => {}
},
}
}
self.focus_handle.focus(window);
} else {
@ -426,14 +423,11 @@ impl BreakpointList {
return;
};
match &mut entry.kind {
BreakpointEntryKind::LineBreakpoint(line_breakpoint) => {
if let BreakpointEntryKind::LineBreakpoint(line_breakpoint) = &mut entry.kind {
let path = line_breakpoint.breakpoint.path.clone();
let row = line_breakpoint.breakpoint.row;
self.edit_line_breakpoint(path, row, BreakpointEditAction::Toggle, cx);
}
_ => {}
}
cx.notify();
}
@ -967,7 +961,7 @@ impl LineBreakpoint {
props,
breakpoint: BreakpointEntry {
kind: BreakpointEntryKind::LineBreakpoint(self.clone()),
weak: weak,
weak,
},
is_selected,
focus_handle,
@ -1179,7 +1173,7 @@ impl ExceptionBreakpoint {
props,
breakpoint: BreakpointEntry {
kind: BreakpointEntryKind::ExceptionBreakpoint(self.clone()),
weak: weak,
weak,
},
is_selected,
focus_handle,

View file

@ -947,7 +947,7 @@ impl VariableList {
#[track_caller]
#[cfg(test)]
pub(crate) fn assert_visual_entries(&self, expected: Vec<&str>) {
const INDENT: &'static str = " ";
const INDENT: &str = " ";
let entries = &self.entries;
let mut visual_entries = Vec::with_capacity(entries.len());

View file

@ -1445,11 +1445,8 @@ async fn test_variable_list_only_sends_requests_when_rendering(
cx.run_until_parked();
let running_state = active_debug_session_panel(workspace, cx).update_in(cx, |item, _, _| {
let state = item.running_state().clone();
state
});
let running_state = active_debug_session_panel(workspace, cx)
.update_in(cx, |item, _, _| item.running_state().clone());
client
.fake_event(dap::messages::Events::Stopped(dap::StoppedEvent {

View file

@ -21,7 +21,7 @@ static KEYMAP_LINUX: LazyLock<KeymapFile> = LazyLock::new(|| {
static ALL_ACTIONS: LazyLock<Vec<ActionDef>> = LazyLock::new(dump_all_gpui_actions);
const FRONT_MATTER_COMMENT: &'static str = "<!-- ZED_META {} -->";
const FRONT_MATTER_COMMENT: &str = "<!-- ZED_META {} -->";
fn main() -> Result<()> {
zlog::init();
@ -105,8 +105,8 @@ fn handle_preprocessing() -> Result<()> {
template_and_validate_actions(&mut book, &mut errors);
if !errors.is_empty() {
const ANSI_RED: &'static str = "\x1b[31m";
const ANSI_RESET: &'static str = "\x1b[0m";
const ANSI_RED: &str = "\x1b[31m";
const ANSI_RESET: &str = "\x1b[0m";
for error in &errors {
eprintln!("{ANSI_RED}ERROR{ANSI_RESET}: {}", error);
}
@ -143,12 +143,9 @@ fn handle_frontmatter(book: &mut Book, errors: &mut HashSet<PreprocessorError>)
&serde_json::to_string(&metadata).expect("Failed to serialize metadata"),
)
});
match new_content {
Cow::Owned(content) => {
if let Cow::Owned(content) = new_content {
chapter.content = content;
}
Cow::Borrowed(_) => {}
}
});
}
@ -409,13 +406,13 @@ fn handle_postprocessing() -> Result<()> {
.captures(contents)
.with_context(|| format!("Failed to find title in {:?}", pretty_path))
.expect("Page has <title> element")[1];
let title = title_tag_contents
title_tag_contents
.trim()
.strip_suffix("- Zed")
.unwrap_or(title_tag_contents)
.trim()
.to_string();
title
.to_string()
}
}

View file

@ -61,14 +61,14 @@ pub fn replacement(c: char) -> Option<&'static str> {
// but could if we tracked state in the classifier.
const IDEOGRAPHIC_SPACE: char = '\u{3000}';
const C0_SYMBOLS: &'static [&'static str] = &[
const C0_SYMBOLS: &[&str] = &[
"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", "", "", "", "", "", "", "", "", "", "", "",
];
const DEL: &'static str = "";
const DEL: &str = "";
// generated using ucd-generate: ucd-generate general-category --include Format --chars ucd-16.0.0
pub const FORMAT: &'static [(char, char)] = &[
pub const FORMAT: &[(char, char)] = &[
('\u{ad}', '\u{ad}'),
('\u{600}', '\u{605}'),
('\u{61c}', '\u{61c}'),
@ -93,7 +93,7 @@ pub const FORMAT: &'static [(char, char)] = &[
];
// hand-made base on https://invisible-characters.com (Excluding Cf)
pub const OTHER: &'static [(char, char)] = &[
pub const OTHER: &[(char, char)] = &[
('\u{034f}', '\u{034f}'),
('\u{115F}', '\u{1160}'),
('\u{17b4}', '\u{17b5}'),
@ -107,7 +107,7 @@ pub const OTHER: &'static [(char, char)] = &[
];
// a subset of FORMAT/OTHER that may appear within glyphs
const PRESERVE: &'static [(char, char)] = &[
const PRESERVE: &[(char, char)] = &[
('\u{034f}', '\u{034f}'),
('\u{200d}', '\u{200d}'),
('\u{17b4}', '\u{17b5}'),

View file

@ -1943,14 +1943,14 @@ impl Editor {
let git_store = project.read(cx).git_store().clone();
let project = project.clone();
project_subscriptions.push(cx.subscribe(&git_store, move |this, _, event, cx| {
match event {
GitStoreEvent::RepositoryUpdated(
if let GitStoreEvent::RepositoryUpdated(
_,
RepositoryEvent::Updated {
new_instance: true, ..
},
_,
) => {
) = event
{
this.load_diff_task = Some(
update_uncommitted_diff_for_buffer(
cx.entity(),
@ -1962,8 +1962,6 @@ impl Editor {
.shared(),
);
}
_ => {}
}
}));
}
@ -3221,9 +3219,8 @@ impl Editor {
selections.select_anchors(other_selections);
});
let other_subscription =
cx.subscribe(&other, |this, other, other_evt, cx| match other_evt {
EditorEvent::SelectionsChanged { local: true } => {
let other_subscription = cx.subscribe(&other, |this, other, other_evt, cx| {
if let EditorEvent::SelectionsChanged { local: true } = other_evt {
let other_selections = other.read(cx).selections.disjoint.to_vec();
if other_selections.is_empty() {
return;
@ -3232,12 +3229,10 @@ impl Editor {
selections.select_anchors(other_selections);
});
}
_ => {}
});
let this_subscription =
cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| match this_evt {
EditorEvent::SelectionsChanged { local: true } => {
let this_subscription = cx.subscribe_self::<EditorEvent>(move |this, this_evt, cx| {
if let EditorEvent::SelectionsChanged { local: true } = this_evt {
let these_selections = this.selections.disjoint.to_vec();
if these_selections.is_empty() {
return;
@ -3248,7 +3243,6 @@ impl Editor {
})
});
}
_ => {}
});
Subscription::join(other_subscription, this_subscription)
@ -5661,19 +5655,18 @@ impl Editor {
let Ok(()) = editor.update_in(cx, |editor, window, cx| {
// Newer menu already set, so exit.
match editor.context_menu.borrow().as_ref() {
Some(CodeContextMenu::Completions(prev_menu)) => {
if prev_menu.id > id {
if let Some(CodeContextMenu::Completions(prev_menu)) =
editor.context_menu.borrow().as_ref()
&& prev_menu.id > id
{
return;
}
}
_ => {}
};
// Only valid to take prev_menu because it the new menu is immediately set
// below, or the menu is hidden.
match editor.context_menu.borrow_mut().take() {
Some(CodeContextMenu::Completions(prev_menu)) => {
if let Some(CodeContextMenu::Completions(prev_menu)) =
editor.context_menu.borrow_mut().take()
{
let position_matches =
if prev_menu.initial_position == menu.initial_position {
true
@ -5687,8 +5680,6 @@ impl Editor {
// try to populate the documentation cache.
menu.preserve_markdown_cache(prev_menu);
}
}
_ => {}
};
menu.set_filter_results(matches, provider, window, cx);
@ -6179,12 +6170,11 @@ impl Editor {
}
});
Some(cx.background_spawn(async move {
let scenarios = futures::future::join_all(scenarios)
futures::future::join_all(scenarios)
.await
.into_iter()
.flatten()
.collect::<Vec<_>>();
scenarios
.collect::<Vec<_>>()
}))
})
.unwrap_or_else(|| Task::ready(vec![]))
@ -7740,12 +7730,9 @@ impl Editor {
self.edit_prediction_settings =
self.edit_prediction_settings_at_position(&buffer, cursor_buffer_position, cx);
match self.edit_prediction_settings {
EditPredictionSettings::Disabled => {
if let EditPredictionSettings::Disabled = self.edit_prediction_settings {
self.discard_edit_prediction(false, cx);
return None;
}
_ => {}
};
self.edit_prediction_indent_conflict = multibuffer.is_line_whitespace_upto(cursor);
@ -10638,8 +10625,7 @@ impl Editor {
.buffer_snapshot
.anchor_after(Point::new(row, line_len));
let bp = self
.breakpoint_store
self.breakpoint_store
.as_ref()?
.read_with(cx, |breakpoint_store, cx| {
breakpoint_store
@ -10664,8 +10650,7 @@ impl Editor {
None
}
})
});
bp
})
}
pub fn edit_log_breakpoint(
@ -10701,7 +10686,7 @@ impl Editor {
let cursors = self
.selections
.disjoint_anchors()
.into_iter()
.iter()
.map(|selection| {
let cursor_position: Point = selection.head().to_point(&snapshot.buffer_snapshot);
@ -14878,7 +14863,7 @@ impl Editor {
let start = parent.start - offset;
offset += parent.len() - text.len();
selections.push(Selection {
id: id,
id,
start,
end: start + text.len(),
reversed: false,
@ -19202,7 +19187,7 @@ impl Editor {
let locations = self
.selections
.all_anchors(cx)
.into_iter()
.iter()
.map(|selection| Location {
buffer: buffer.clone(),
range: selection.start.text_anchor..selection.end.text_anchor,
@ -19914,12 +19899,9 @@ impl Editor {
event: &SessionEvent,
cx: &mut Context<Self>,
) {
match event {
SessionEvent::InvalidateInlineValue => {
if let SessionEvent::InvalidateInlineValue = event {
self.refresh_inline_values(cx);
}
_ => {}
}
}
pub fn refresh_inline_values(&mut self, cx: &mut Context<Self>) {

View file

@ -21037,7 +21037,7 @@ fn assert_breakpoint(
let mut breakpoint = breakpoints
.get(path)
.unwrap()
.into_iter()
.iter()
.map(|breakpoint| {
(
breakpoint.row,
@ -23622,7 +23622,7 @@ pub fn handle_completion_request(
complete_from_position
);
Ok(Some(lsp::CompletionResponse::List(lsp::CompletionList {
is_incomplete: is_incomplete,
is_incomplete,
item_defaults: None,
items: completions
.iter()

View file

@ -724,7 +724,7 @@ impl EditorElement {
ColumnarMode::FromMouse => true,
ColumnarMode::FromSelection => false,
},
mode: mode,
mode,
goal_column: point_for_position.exact_unclipped.column(),
},
window,
@ -2437,14 +2437,13 @@ impl EditorElement {
.unwrap_or_default()
.padding as f32;
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref() {
match &edit_prediction.completion {
EditPrediction::Edit {
if let Some(edit_prediction) = editor.active_edit_prediction.as_ref()
&& let EditPrediction::Edit {
display_mode: EditDisplayMode::TabAccept,
..
} => padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS,
_ => {}
}
} = &edit_prediction.completion
{
padding += INLINE_ACCEPT_SUGGESTION_EM_WIDTHS
}
padding * em_width
@ -2978,8 +2977,8 @@ impl EditorElement {
.ilog10()
+ 1;
let elements = buffer_rows
.into_iter()
buffer_rows
.iter()
.enumerate()
.map(|(ix, row_info)| {
let ExpandInfo {
@ -3034,9 +3033,7 @@ impl EditorElement {
Some((toggle, origin))
})
.collect();
elements
.collect()
}
fn calculate_relative_line_numbers(
@ -3136,7 +3133,7 @@ impl EditorElement {
let relative_rows = self.calculate_relative_line_numbers(snapshot, &rows, relative_to);
let mut line_number = String::new();
let line_numbers = buffer_rows
.into_iter()
.iter()
.enumerate()
.flat_map(|(ix, row_info)| {
let display_row = DisplayRow(rows.start.0 + ix as u32);
@ -3213,7 +3210,7 @@ impl EditorElement {
&& self.editor.read(cx).is_singleton(cx);
if include_fold_statuses {
row_infos
.into_iter()
.iter()
.enumerate()
.map(|(ix, info)| {
if info.expand_info.is_some() {

View file

@ -213,8 +213,8 @@ impl GitBlame {
let project_subscription = cx.subscribe(&project, {
let buffer = buffer.clone();
move |this, _, event, cx| match event {
project::Event::WorktreeUpdatedEntries(_, updated) => {
move |this, _, event, cx| {
if let project::Event::WorktreeUpdatedEntries(_, updated) = event {
let project_entry_id = buffer.read(cx).entry_id(cx);
if updated
.iter()
@ -224,7 +224,6 @@ impl GitBlame {
this.generate(cx);
}
}
_ => {}
}
});
@ -292,7 +291,7 @@ impl GitBlame {
let buffer_id = self.buffer_snapshot.remote_id();
let mut cursor = self.entries.cursor::<u32>(&());
rows.into_iter().map(move |info| {
rows.iter().map(move |info| {
let row = info
.buffer_row
.filter(|_| info.buffer_id == Some(buffer_id))?;

View file

@ -603,8 +603,7 @@ async fn parse_blocks(
})
.join("\n\n");
let rendered_block = cx
.new_window_entity(|_window, cx| {
cx.new_window_entity(|_window, cx| {
Markdown::new(
combined_text.into(),
language_registry.cloned(),
@ -612,9 +611,7 @@ async fn parse_blocks(
cx,
)
})
.ok();
rendered_block
.ok()
}
pub fn hover_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {

View file

@ -1009,16 +1009,12 @@ impl Item for Editor {
) {
self.workspace = Some((workspace.weak_handle(), workspace.database_id()));
if let Some(workspace) = &workspace.weak_handle().upgrade() {
cx.subscribe(
workspace,
|editor, _, event: &workspace::Event, _cx| match event {
workspace::Event::ModalOpened => {
cx.subscribe(workspace, |editor, _, event: &workspace::Event, _cx| {
if let workspace::Event::ModalOpened = event {
editor.mouse_context_menu.take();
editor.inline_blame_popover.take();
}
_ => {}
},
)
})
.detach();
}
}

View file

@ -808,10 +808,7 @@ mod jsx_tag_autoclose_tests {
);
buf
});
let buffer_c = cx.new(|cx| {
let buf = language::Buffer::local("<span", cx);
buf
});
let buffer_c = cx.new(|cx| language::Buffer::local("<span", cx));
let buffer = cx.new(|cx| {
let mut buf = MultiBuffer::new(language::Capability::ReadWrite);
buf.push_excerpts(

View file

@ -241,8 +241,7 @@ impl ProposedChangesEditor {
event: &BufferEvent,
_cx: &mut Context<Self>,
) {
match event {
BufferEvent::Operation { .. } => {
if let BufferEvent::Operation { .. } = event {
self.recalculate_diffs_tx
.unbounded_send(RecalculateDiff {
buffer,
@ -250,16 +249,6 @@ impl ProposedChangesEditor {
})
.ok();
}
// BufferEvent::DiffBaseChanged => {
// self.recalculate_diffs_tx
// .unbounded_send(RecalculateDiff {
// buffer,
// debounce: false,
// })
// .ok();
// }
_ => (),
}
}
}

View file

@ -119,8 +119,8 @@ impl SelectionsCollection {
cx: &mut App,
) -> Option<Selection<D>> {
let map = self.display_map(cx);
let selection = resolve_selections(self.pending_anchor().as_ref(), &map).next();
selection
resolve_selections(self.pending_anchor().as_ref(), &map).next()
}
pub(crate) fn pending_mode(&self) -> Option<SelectMode> {
@ -276,18 +276,18 @@ impl SelectionsCollection {
cx: &mut App,
) -> Selection<D> {
let map = self.display_map(cx);
let selection = resolve_selections([self.newest_anchor()], &map)
resolve_selections([self.newest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn newest_display(&self, cx: &mut App) -> Selection<DisplayPoint> {
let map = self.display_map(cx);
let selection = resolve_selections_display([self.newest_anchor()], &map)
resolve_selections_display([self.newest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn oldest_anchor(&self) -> &Selection<Anchor> {
@ -303,10 +303,10 @@ impl SelectionsCollection {
cx: &mut App,
) -> Selection<D> {
let map = self.display_map(cx);
let selection = resolve_selections([self.oldest_anchor()], &map)
resolve_selections([self.oldest_anchor()], &map)
.next()
.unwrap();
selection
.unwrap()
}
pub fn first_anchor(&self) -> Selection<Anchor> {

View file

@ -678,8 +678,8 @@ pub fn wait_for_lang_server(
[
cx.subscribe(&lsp_store, {
let log_prefix = log_prefix.clone();
move |_, event, _| match event {
project::LspStoreEvent::LanguageServerUpdate {
move |_, event, _| {
if let project::LspStoreEvent::LanguageServerUpdate {
message:
client::proto::update_language_server::Variant::WorkProgress(
LspWorkProgress {
@ -688,8 +688,10 @@ pub fn wait_for_lang_server(
},
),
..
} => println!("{}{message}", log_prefix),
_ => {}
} = event
{
println!("{}{message}", log_prefix)
}
}
}),
cx.subscribe(project, {

View file

@ -484,15 +484,11 @@ impl ExtensionBuilder {
_ => {}
}
match &payload {
CustomSection(c) => {
if strip_custom_section(c.name()) {
if let CustomSection(c) = &payload
&& strip_custom_section(c.name())
{
continue;
}
}
_ => {}
}
if let Some((id, range)) = payload.as_section() {
RawSection {
id,

View file

@ -1675,9 +1675,8 @@ impl ExtensionStore {
let schema_path = &extension::build_debug_adapter_schema_path(adapter_name, meta);
if fs.is_file(&src_dir.join(schema_path)).await {
match schema_path.parent() {
Some(parent) => fs.create_dir(&tmp_dir.join(parent)).await?,
None => {}
if let Some(parent) = schema_path.parent() {
fs.create_dir(&tmp_dir.join(parent)).await?
}
fs.copy_file(
&src_dir.join(schema_path),

View file

@ -532,7 +532,7 @@ fn wasm_engine(executor: &BackgroundExecutor) -> wasmtime::Engine {
// `Future::poll`.
const EPOCH_INTERVAL: Duration = Duration::from_millis(100);
let mut timer = Timer::interval(EPOCH_INTERVAL);
while let Some(_) = timer.next().await {
while (timer.next().await).is_some() {
// Exit the loop and thread once the engine is dropped.
let Some(engine) = engine_ref.upgrade() else {
break;

View file

@ -863,7 +863,7 @@ impl ExtensionsPage {
window: &mut Window,
cx: &mut App,
) -> Entity<ContextMenu> {
let context_menu = ContextMenu::build(window, cx, |context_menu, window, _| {
ContextMenu::build(window, cx, |context_menu, window, _| {
context_menu
.entry(
"Install Another Version...",
@ -887,9 +887,7 @@ impl ExtensionsPage {
cx.write_to_clipboard(ClipboardItem::new_string(authors.join(", ")));
}
})
});
context_menu
})
}
fn show_extension_version_list(

View file

@ -112,7 +112,7 @@ impl OpenPathDelegate {
entries,
..
} => user_input
.into_iter()
.iter()
.filter(|user_input| !user_input.exists || !user_input.is_dir)
.map(|user_input| user_input.file.string.clone())
.chain(self.string_matches.iter().filter_map(|string_match| {

View file

@ -2419,12 +2419,11 @@ impl Fs for FakeFs {
let watcher = watcher.clone();
move |events| {
let result = events.iter().any(|evt_path| {
let result = watcher
watcher
.prefixes
.lock()
.iter()
.any(|prefix| evt_path.path.starts_with(prefix));
result
.any(|prefix| evt_path.path.starts_with(prefix))
});
let executor = executor.clone();
async move {

View file

@ -2028,7 +2028,7 @@ fn parse_branch_input(input: &str) -> Result<Vec<Branch>> {
branches.push(Branch {
is_head: is_current_branch,
ref_name: ref_name,
ref_name,
most_recent_commit: Some(CommitSummary {
sha: head_sha,
subject,

View file

@ -123,7 +123,7 @@ impl FileDiffView {
old_buffer,
new_buffer,
_recalculate_diff_task: cx.spawn(async move |this, cx| {
while let Ok(_) = buffer_changes_rx.recv().await {
while buffer_changes_rx.recv().await.is_ok() {
loop {
let mut timer = cx
.background_executor()

View file

@ -426,7 +426,7 @@ impl GitPanel {
let git_store = project.read(cx).git_store().clone();
let active_repository = project.read(cx).active_repository(cx);
let git_panel = cx.new(|cx| {
cx.new(|cx| {
let focus_handle = cx.focus_handle();
cx.on_focus(&focus_handle, window, Self::focus_in).detach();
cx.on_focus_out(&focus_handle, window, |this, _, window, cx| {
@ -563,9 +563,7 @@ impl GitPanel {
this.schedule_update(false, window, cx);
this
});
git_panel
})
}
fn hide_scrollbars(&mut self, window: &mut Window, cx: &mut Context<Self>) {
@ -1198,14 +1196,13 @@ impl GitPanel {
window,
cx,
);
cx.spawn(async move |this, cx| match prompt.await {
Ok(RestoreCancel::RestoreTrackedFiles) => {
cx.spawn(async move |this, cx| {
if let Ok(RestoreCancel::RestoreTrackedFiles) = prompt.await {
this.update(cx, |this, cx| {
this.perform_checkout(entries, cx);
})
.ok();
}
_ => {}
})
.detach();
}

View file

@ -346,8 +346,7 @@ impl ProjectDiff {
window: &mut Window,
cx: &mut Context<Self>,
) {
match event {
EditorEvent::SelectionsChanged { local: true } => {
if let EditorEvent::SelectionsChanged { local: true } = event {
let Some(project_path) = self.active_path(cx) else {
return;
};
@ -361,8 +360,6 @@ impl ProjectDiff {
})
.ok();
}
_ => {}
}
if editor.focus_handle(cx).contains_focused(window, cx)
&& self.multibuffer.read(cx).is_empty()
{
@ -513,7 +510,7 @@ impl ProjectDiff {
mut recv: postage::watch::Receiver<()>,
cx: &mut AsyncWindowContext,
) -> Result<()> {
while let Some(_) = recv.next().await {
while (recv.next().await).is_some() {
let buffers_to_load = this.update(cx, |this, cx| this.load_buffers(cx))?;
for buffer_to_load in buffers_to_load {
if let Some(buffer) = buffer_to_load.await.log_err() {

View file

@ -207,7 +207,7 @@ impl TextDiffView {
path: Some(format!("Clipboard ↔ {selection_location_path}").into()),
buffer_changes_tx,
_recalculate_diff_task: cx.spawn(async move |_, cx| {
while let Ok(_) = buffer_changes_rx.recv().await {
while buffer_changes_rx.recv().await.is_ok() {
loop {
let mut timer = cx
.background_executor()

View file

@ -1707,8 +1707,8 @@ impl App {
.unwrap_or_else(|| {
is_first = true;
let future = A::load(source.clone(), self);
let task = self.background_executor().spawn(future).shared();
task
self.background_executor().spawn(future).shared()
});
self.loading_assets.insert(asset_id, Box::new(task.clone()));

View file

@ -326,7 +326,7 @@ impl TextLayout {
vec![text_style.to_run(text.len())]
};
let layout_id = window.request_measured_layout(Default::default(), {
window.request_measured_layout(Default::default(), {
let element_state = self.clone();
move |known_dimensions, available_space, window, cx| {
@ -416,9 +416,7 @@ impl TextLayout {
size
}
});
layout_id
})
}
fn prepaint(&self, bounds: Bounds<Pixels>, text: &str) {

View file

@ -949,12 +949,9 @@ impl Dispatch<WlCallback, ObjectId> for WaylandClientStatePtr {
};
drop(state);
match event {
wl_callback::Event::Done { .. } => {
if let wl_callback::Event::Done { .. } = event {
window.frame();
}
_ => {}
}
}
}
@ -2014,8 +2011,7 @@ impl Dispatch<wl_data_offer::WlDataOffer, ()> for WaylandClientStatePtr {
let client = this.get_client();
let mut state = client.borrow_mut();
match event {
wl_data_offer::Event::Offer { mime_type } => {
if let wl_data_offer::Event::Offer { mime_type } = event {
// Drag and drop
if mime_type == FILE_LIST_MIME_TYPE {
let serial = state.serial_tracker.get(SerialKind::DataDevice);
@ -2032,8 +2028,6 @@ impl Dispatch<wl_data_offer::WlDataOffer, ()> for WaylandClientStatePtr {
offer.add_mime_type(mime_type);
}
}
_ => {}
}
}
}
@ -2113,15 +2107,12 @@ impl Dispatch<zwp_primary_selection_offer_v1::ZwpPrimarySelectionOfferV1, ()>
let client = this.get_client();
let mut state = client.borrow_mut();
match event {
zwp_primary_selection_offer_v1::Event::Offer { mime_type } => {
if let Some(offer) = state.primary_data_offer.as_mut() {
if let zwp_primary_selection_offer_v1::Event::Offer { mime_type } = event
&& let Some(offer) = state.primary_data_offer.as_mut()
{
offer.add_mime_type(mime_type);
}
}
_ => {}
}
}
}
impl Dispatch<zwp_primary_selection_source_v1::ZwpPrimarySelectionSourceV1, ()>

View file

@ -355,8 +355,7 @@ impl WaylandWindowStatePtr {
}
pub fn handle_xdg_surface_event(&self, event: xdg_surface::Event) {
match event {
xdg_surface::Event::Configure { serial } => {
if let xdg_surface::Event::Configure { serial } = event {
{
let mut state = self.state.borrow_mut();
if let Some(window_controls) = state.in_progress_window_controls.take() {
@ -427,13 +426,11 @@ impl WaylandWindowStatePtr {
self.frame();
}
}
_ => {}
}
}
pub fn handle_toplevel_decoration_event(&self, event: zxdg_toplevel_decoration_v1::Event) {
match event {
zxdg_toplevel_decoration_v1::Event::Configure { mode } => match mode {
if let zxdg_toplevel_decoration_v1::Event::Configure { mode } = event {
match mode {
WEnum::Value(zxdg_toplevel_decoration_v1::Mode::ServerSide) => {
self.state.borrow_mut().decorations = WindowDecorations::Server;
if let Some(mut appearance_changed) =
@ -457,18 +454,14 @@ impl WaylandWindowStatePtr {
WEnum::Unknown(v) => {
log::warn!("Unknown decoration mode: {}", v);
}
},
_ => {}
}
}
}
pub fn handle_fractional_scale_event(&self, event: wp_fractional_scale_v1::Event) {
match event {
wp_fractional_scale_v1::Event::PreferredScale { scale } => {
if let wp_fractional_scale_v1::Event::PreferredScale { scale } = event {
self.rescale(scale as f32 / 120.0);
}
_ => {}
}
}
pub fn handle_toplevel_event(&self, event: xdg_toplevel::Event) -> bool {

View file

@ -232,16 +232,13 @@ impl X11ClientStatePtr {
};
let mut state = client.0.borrow_mut();
if let Some(window_ref) = state.windows.remove(&x_window) {
match window_ref.refresh_state {
Some(RefreshState::PeriodicRefresh {
if let Some(window_ref) = state.windows.remove(&x_window)
&& let Some(RefreshState::PeriodicRefresh {
event_loop_token, ..
}) => {
}) = window_ref.refresh_state
{
state.loop_handle.remove(event_loop_token);
}
_ => {}
}
}
if state.mouse_focused_window == Some(x_window) {
state.mouse_focused_window = None;
}
@ -876,8 +873,7 @@ impl X11Client {
let Some(reply) = reply else {
return Some(());
};
match str::from_utf8(&reply.value) {
Ok(file_list) => {
if let Ok(file_list) = str::from_utf8(&reply.value) {
let paths: SmallVec<[_; 2]> = file_list
.lines()
.filter_map(|path| Url::parse(path).log_err())
@ -891,8 +887,6 @@ impl X11Client {
window.handle_input(input);
self.0.borrow_mut().xdnd_state.retrieved = true;
}
Err(_) => {}
}
}
Event::ConfigureNotify(event) => {
let bounds = Bounds {

View file

@ -426,7 +426,7 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
key_char = Some(chars_for_modified_key(native_event.keyCode(), mods));
}
let mut key = if shift
if shift
&& chars_ignoring_modifiers
.chars()
.all(|c| c.is_ascii_lowercase())
@ -437,9 +437,7 @@ unsafe fn parse_keystroke(native_event: id) -> Keystroke {
chars_with_shift
} else {
chars_ignoring_modifiers
};
key
}
}
};

View file

@ -2063,8 +2063,8 @@ fn screen_point_to_gpui_point(this: &Object, position: NSPoint) -> Point<Pixels>
let frame = get_frame(this);
let window_x = position.x - frame.origin.x;
let window_y = frame.size.height - (position.y - frame.origin.y);
let position = point(px(window_x as f32), px(window_y as f32));
position
point(px(window_x as f32), px(window_y as f32))
}
extern "C" fn dragging_entered(this: &Object, _: Sel, dragging_info: id) -> NSDragOperation {

View file

@ -228,7 +228,7 @@ fn run_capture(
display,
size,
}));
if let Err(_) = stream_send_result {
if stream_send_result.is_err() {
return;
}
while !cancel_stream.load(std::sync::atomic::Ordering::SeqCst) {

View file

@ -1128,8 +1128,7 @@ impl WindowsWindowInner {
&& let Some(parameter_string) = unsafe { parameter.to_string() }.log_err()
{
log::info!("System settings changed: {}", parameter_string);
match parameter_string.as_str() {
"ImmersiveColorSet" => {
if parameter_string.as_str() == "ImmersiveColorSet" {
let new_appearance = system_appearance()
.context("unable to get system appearance when handling ImmersiveColorSet")
.log_err()?;
@ -1143,8 +1142,6 @@ impl WindowsWindowInner {
configure_dwm_dark_mode(handle, new_appearance);
}
}
_ => {}
}
}
Some(0)
}
@ -1469,7 +1466,7 @@ pub(crate) fn current_modifiers() -> Modifiers {
#[inline]
pub(crate) fn current_capslock() -> Capslock {
let on = unsafe { GetKeyState(VK_CAPITAL.0 as i32) & 1 } > 0;
Capslock { on: on }
Capslock { on }
}
fn get_client_area_insets(

View file

@ -58,23 +58,21 @@ impl TaffyLayoutEngine {
children: &[LayoutId],
) -> LayoutId {
let taffy_style = style.to_taffy(rem_size);
let layout_id = if children.is_empty() {
if children.is_empty() {
self.taffy
.new_leaf(taffy_style)
.expect(EXPECT_MESSAGE)
.into()
} else {
let parent_id = self
.taffy
self.taffy
// This is safe because LayoutId is repr(transparent) to taffy::tree::NodeId.
.new_with_children(taffy_style, unsafe {
std::mem::transmute::<&[LayoutId], &[taffy::NodeId]>(children)
})
.expect(EXPECT_MESSAGE)
.into();
parent_id
};
layout_id
.into()
}
}
pub fn request_measured_layout(
@ -91,8 +89,7 @@ impl TaffyLayoutEngine {
) -> LayoutId {
let taffy_style = style.to_taffy(rem_size);
let layout_id = self
.taffy
self.taffy
.new_leaf_with_context(
taffy_style,
NodeContext {
@ -100,8 +97,7 @@ impl TaffyLayoutEngine {
},
)
.expect(EXPECT_MESSAGE)
.into();
layout_id
.into()
}
// Used to understand performance

View file

@ -44,7 +44,7 @@ impl LineWrapper {
let mut prev_c = '\0';
let mut index = 0;
let mut candidates = fragments
.into_iter()
.iter()
.flat_map(move |fragment| fragment.wrap_boundary_candidates())
.peekable();
iter::from_fn(move || {

View file

@ -58,13 +58,7 @@ pub trait FluentBuilder {
where
Self: Sized,
{
self.map(|this| {
if let Some(_) = option {
this
} else {
then(this)
}
})
self.map(|this| if option.is_some() { this } else { then(this) })
}
}

View file

@ -86,7 +86,7 @@ impl Parse for Args {
Ok(Args {
seeds,
max_retries,
max_iterations: max_iterations,
max_iterations,
on_failure_fn_name,
})
}

View file

@ -435,8 +435,7 @@ impl HttpClient for FakeHttpClient {
&self,
req: Request<AsyncBody>,
) -> BoxFuture<'static, anyhow::Result<Response<AsyncBody>>> {
let future = (self.handler.lock().as_ref().unwrap())(req);
future
((self.handler.lock().as_ref().unwrap())(req)) as _
}
fn user_agent(&self) -> Option<&HeaderValue> {

View file

@ -50,16 +50,13 @@ impl RealJujutsuRepository {
impl JujutsuRepository for RealJujutsuRepository {
fn list_bookmarks(&self) -> Vec<Bookmark> {
let bookmarks = self
.repository
self.repository
.view()
.bookmarks()
.map(|(ref_name, _target)| Bookmark {
ref_name: ref_name.as_str().to_string().into(),
})
.collect();
bookmarks
.collect()
}
}

View file

@ -195,11 +195,9 @@ pub fn new_journal_entry(workspace: &Workspace, window: &mut Window, cx: &mut Ap
}
fn journal_dir(path: &str) -> Option<PathBuf> {
let expanded_journal_dir = shellexpand::full(path) //TODO handle this better
shellexpand::full(path) //TODO handle this better
.ok()
.map(|dir| Path::new(&dir.to_string()).to_path_buf().join("journal"));
expanded_journal_dir
.map(|dir| Path::new(&dir.to_string()).to_path_buf().join("journal"))
}
fn heading_entry(now: NaiveTime, hour_format: &Option<HourFormat>) -> String {

View file

@ -1128,7 +1128,7 @@ impl Buffer {
} else {
ranges.as_slice()
}
.into_iter()
.iter()
.peekable();
let mut edits = Vec::new();
@ -1395,7 +1395,8 @@ impl Buffer {
is_first = false;
return true;
}
let any_sub_ranges_contain_range = layer
layer
.included_sub_ranges
.map(|sub_ranges| {
sub_ranges.iter().any(|sub_range| {
@ -1404,9 +1405,7 @@ impl Buffer {
!is_before_start && !is_after_end
})
})
.unwrap_or(true);
let result = any_sub_ranges_contain_range;
result
.unwrap_or(true)
})
.last()
.map(|info| info.language.clone())
@ -2616,7 +2615,7 @@ impl Buffer {
self.completion_triggers = self
.completion_triggers_per_language_server
.values()
.flat_map(|triggers| triggers.into_iter().cloned())
.flat_map(|triggers| triggers.iter().cloned())
.collect();
} else {
self.completion_triggers_per_language_server
@ -2776,7 +2775,7 @@ impl Buffer {
self.completion_triggers = self
.completion_triggers_per_language_server
.values()
.flat_map(|triggers| triggers.into_iter().cloned())
.flat_map(|triggers| triggers.iter().cloned())
.collect();
} else {
self.completion_triggers_per_language_server

View file

@ -1513,9 +1513,8 @@ impl Language {
.map(|ix| {
let mut config = BracketsPatternConfig::default();
for setting in query.property_settings(ix) {
match setting.key.as_ref() {
"newline.only" => config.newline_only = true,
_ => {}
if setting.key.as_ref() == "newline.only" {
config.newline_only = true
}
}
config

View file

@ -300,7 +300,7 @@ impl From<AnthropicError> for LanguageModelCompletionError {
},
AnthropicError::ServerOverloaded { retry_after } => Self::ServerOverloaded {
provider,
retry_after: retry_after,
retry_after,
},
AnthropicError::ApiError(api_error) => api_error.into(),
}

View file

@ -404,7 +404,7 @@ pub fn into_open_ai(
match content {
MessageContent::Text(text) | MessageContent::Thinking { text, .. } => {
add_message_content_part(
open_ai::MessagePart::Text { text: text },
open_ai::MessagePart::Text { text },
message.role,
&mut messages,
)

View file

@ -234,7 +234,7 @@ impl JsonLspAdapter {
schemas
.as_array_mut()
.unwrap()
.extend(cx.all_action_names().into_iter().map(|&name| {
.extend(cx.all_action_names().iter().map(|&name| {
project::lsp_store::json_language_server_ext::url_schema_for_action(name)
}));

View file

@ -711,7 +711,7 @@ impl Default for PythonToolchainProvider {
}
}
static ENV_PRIORITY_LIST: &'static [PythonEnvironmentKind] = &[
static ENV_PRIORITY_LIST: &[PythonEnvironmentKind] = &[
// Prioritize non-Conda environments.
PythonEnvironmentKind::Poetry,
PythonEnvironmentKind::Pipenv,

View file

@ -5205,14 +5205,10 @@ impl MultiBufferSnapshot {
if offset == diff_transforms.start().0
&& bias == Bias::Left
&& let Some(prev_item) = diff_transforms.prev_item()
&& let DiffTransform::DeletedHunk { .. } = prev_item
{
match prev_item {
DiffTransform::DeletedHunk { .. } => {
diff_transforms.prev();
}
_ => {}
}
}
let offset_in_transform = offset - diff_transforms.start().0;
let mut excerpt_offset = diff_transforms.start().1;
let mut diff_base_anchor = None;

View file

@ -76,9 +76,8 @@ impl NodeRuntime {
let mut state = self.0.lock().await;
let options = loop {
match state.options.borrow().as_ref() {
Some(options) => break options.clone(),
None => {}
if let Some(options) = state.options.borrow().as_ref() {
break options.clone();
}
match state.options.changed().await {
Ok(()) => {}

View file

@ -19,7 +19,7 @@ use util::ResultExt;
use workspace::{ModalView, Workspace};
use zed_actions::agent::OpenSettings;
const FEATURED_PROVIDERS: [&'static str; 4] = ["anthropic", "google", "openai", "ollama"];
const FEATURED_PROVIDERS: [&str; 4] = ["anthropic", "google", "openai", "ollama"];
fn render_llm_provider_section(
tab_index: &mut isize,
@ -410,7 +410,7 @@ impl AiPrivacyTooltip {
impl Render for AiPrivacyTooltip {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
const DESCRIPTION: &'static str = "We believe in opt-in data sharing as the default for building AI products, rather than opt-out. We'll only use or store your data if you affirmatively send it to us. ";
const DESCRIPTION: &str = "We believe in opt-in data sharing as the default for building AI products, rather than opt-out. We'll only use or store your data if you affirmatively send it to us. ";
tooltip_container(window, cx, move |this, _, _| {
this.child(

View file

@ -16,8 +16,8 @@ use vim_mode_setting::VimModeSetting;
use crate::theme_preview::{ThemePreviewStyle, ThemePreviewTile};
const LIGHT_THEMES: [&'static str; 3] = ["One Light", "Ayu Light", "Gruvbox Light"];
const DARK_THEMES: [&'static str; 3] = ["One Dark", "Ayu Dark", "Gruvbox Dark"];
const LIGHT_THEMES: [&str; 3] = ["One Light", "Ayu Light", "Gruvbox Light"];
const DARK_THEMES: [&str; 3] = ["One Dark", "Ayu Dark", "Gruvbox Dark"];
const FAMILY_NAMES: [SharedString; 3] = [
SharedString::new_static("One"),
SharedString::new_static("Ayu"),
@ -114,7 +114,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement
let themes = theme_names.map(|theme| theme_registry.get(theme).unwrap());
let theme_previews = [0, 1, 2].map(|index| {
[0, 1, 2].map(|index| {
let theme = &themes[index];
let is_selected = theme.name == current_theme_name;
let name = theme.name.clone();
@ -176,9 +176,7 @@ fn render_theme_section(tab_index: &mut isize, cx: &mut App) -> impl IntoElement
.color(Color::Muted)
.size(LabelSize::Small),
)
});
theme_previews
})
}
fn write_mode_change(mode: ThemeMode, cx: &mut App) {

View file

@ -605,7 +605,7 @@ fn render_popular_settings_section(
window: &mut Window,
cx: &mut App,
) -> impl IntoElement {
const LIGATURE_TOOLTIP: &'static str =
const LIGATURE_TOOLTIP: &str =
"Font ligatures combine two characters into one. For example, turning =/= into ≠.";
v_flex()

View file

@ -733,7 +733,8 @@ impl OutlinePanel {
) -> Entity<Self> {
let project = workspace.project().clone();
let workspace_handle = cx.entity().downgrade();
let outline_panel = cx.new(|cx| {
cx.new(|cx| {
let filter_editor = cx.new(|cx| {
let mut editor = Editor::single_line(window, cx);
editor.set_placeholder_text("Filter...", cx);
@ -912,9 +913,7 @@ impl OutlinePanel {
outline_panel.replace_active_editor(item, editor, window, cx);
}
outline_panel
});
outline_panel
})
}
fn serialization_key(workspace: &Workspace) -> Option<String> {
@ -2624,7 +2623,7 @@ impl OutlinePanel {
}
fn entry_name(&self, worktree_id: &WorktreeId, entry: &Entry, cx: &App) -> String {
let name = match self.project.read(cx).worktree_for_id(*worktree_id, cx) {
match self.project.read(cx).worktree_for_id(*worktree_id, cx) {
Some(worktree) => {
let worktree = worktree.read(cx);
match worktree.snapshot().root_entry() {
@ -2645,8 +2644,7 @@ impl OutlinePanel {
}
}
None => file_name(entry.path.as_ref()),
};
name
}
}
fn update_fs_entries(
@ -2681,7 +2679,8 @@ impl OutlinePanel {
new_collapsed_entries = outline_panel.collapsed_entries.clone();
new_unfolded_dirs = outline_panel.unfolded_dirs.clone();
let multi_buffer_snapshot = active_multi_buffer.read(cx).snapshot(cx);
let buffer_excerpts = multi_buffer_snapshot.excerpts().fold(
multi_buffer_snapshot.excerpts().fold(
HashMap::default(),
|mut buffer_excerpts, (excerpt_id, buffer_snapshot, excerpt_range)| {
let buffer_id = buffer_snapshot.remote_id();
@ -2728,8 +2727,7 @@ impl OutlinePanel {
);
buffer_excerpts
},
);
buffer_excerpts
)
}) else {
return;
};
@ -4807,7 +4805,7 @@ impl OutlinePanel {
.with_compute_indents_fn(cx.entity(), |outline_panel, range, _, _| {
let entries = outline_panel.cached_entries.get(range);
if let Some(entries) = entries {
entries.into_iter().map(|item| item.depth).collect()
entries.iter().map(|item| item.depth).collect()
} else {
smallvec::SmallVec::new()
}

View file

@ -413,14 +413,11 @@ impl LocalBufferStore {
cx: &mut Context<BufferStore>,
) {
cx.subscribe(worktree, |this, worktree, event, cx| {
if worktree.read(cx).is_local() {
match event {
worktree::Event::UpdatedEntries(changes) => {
if worktree.read(cx).is_local()
&& let worktree::Event::UpdatedEntries(changes) = event
{
Self::local_worktree_entries_changed(this, &worktree, changes, cx);
}
_ => {}
}
}
})
.detach();
}
@ -947,10 +944,9 @@ impl BufferStore {
}
pub fn get_by_path(&self, path: &ProjectPath) -> Option<Entity<Buffer>> {
self.path_to_buffer_id.get(path).and_then(|buffer_id| {
let buffer = self.get(*buffer_id);
buffer
})
self.path_to_buffer_id
.get(path)
.and_then(|buffer_id| self.get(*buffer_id))
}
pub fn get(&self, buffer_id: BufferId) -> Option<Entity<Buffer>> {

View file

@ -4,8 +4,8 @@ use gpui::{Hsla, Rgba};
use lsp::{CompletionItem, Documentation};
use regex::{Regex, RegexBuilder};
const HEX: &'static str = r#"(#(?:[\da-fA-F]{3}){1,2})"#;
const RGB_OR_HSL: &'static str = r#"(rgba?|hsla?)\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*(?:,\s*(1|0?\.\d+))?\s*\)"#;
const HEX: &str = r#"(#(?:[\da-fA-F]{3}){1,2})"#;
const RGB_OR_HSL: &str = r#"(rgba?|hsla?)\(\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*(?:,\s*(1|0?\.\d+))?\s*\)"#;
static RELAXED_HEX_REGEX: LazyLock<Regex> = LazyLock::new(|| {
RegexBuilder::new(HEX)
@ -141,7 +141,7 @@ mod tests {
use gpui::rgba;
use lsp::{CompletionItem, CompletionItemKind};
pub const COLOR_TABLE: &[(&'static str, Option<u32>)] = &[
pub const COLOR_TABLE: &[(&str, Option<u32>)] = &[
// -- Invalid --
// Invalid hex
("f0f", None),

View file

@ -642,8 +642,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_status(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let (_fs, project) = setup_context_server_test(
cx,
@ -722,8 +722,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_status_events(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let (_fs, project) = setup_context_server_test(
cx,
@ -784,7 +784,7 @@ mod tests {
#[gpui::test(iterations = 25)]
async fn test_context_server_concurrent_starts(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_1_ID: &str = "mcp-1";
let (_fs, project) = setup_context_server_test(
cx,
@ -845,8 +845,8 @@ mod tests {
#[gpui::test]
async fn test_context_server_maintain_servers_loop(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_2_ID: &'static str = "mcp-2";
const SERVER_1_ID: &str = "mcp-1";
const SERVER_2_ID: &str = "mcp-2";
let server_1_id = ContextServerId(SERVER_1_ID.into());
let server_2_id = ContextServerId(SERVER_2_ID.into());
@ -1084,7 +1084,7 @@ mod tests {
#[gpui::test]
async fn test_context_server_enabled_disabled(cx: &mut TestAppContext) {
const SERVER_1_ID: &'static str = "mcp-1";
const SERVER_1_ID: &str = "mcp-1";
let server_1_id = ContextServerId(SERVER_1_ID.into());

View file

@ -470,9 +470,8 @@ impl DapStore {
session_id: impl Borrow<SessionId>,
) -> Option<Entity<session::Session>> {
let session_id = session_id.borrow();
let client = self.sessions.get(session_id).cloned();
client
self.sessions.get(session_id).cloned()
}
pub fn sessions(&self) -> impl Iterator<Item = &Entity<Session>> {
self.sessions.values()

View file

@ -174,7 +174,7 @@ impl DapLocator for GoLocator {
request: "launch".to_string(),
mode: "test".to_string(),
program,
args: args,
args,
build_flags,
cwd: build_config.cwd.clone(),
env: build_config.env.clone(),
@ -185,7 +185,7 @@ impl DapLocator for GoLocator {
label: resolved_label.to_string().into(),
adapter: adapter.0.clone(),
build: None,
config: config,
config,
tcp_connection: None,
})
}
@ -220,7 +220,7 @@ impl DapLocator for GoLocator {
request: "launch".to_string(),
mode: "debug".to_string(),
program,
args: args,
args,
build_flags,
})
.unwrap();

View file

@ -226,7 +226,7 @@ impl RunningMode {
fn unset_breakpoints_from_paths(&self, paths: &Vec<Arc<Path>>, cx: &mut App) -> Task<()> {
let tasks: Vec<_> = paths
.into_iter()
.iter()
.map(|path| {
self.request(dap_command::SetBreakpoints {
source: client_source(path),
@ -508,13 +508,12 @@ impl RunningMode {
.ok();
}
let ret = if configuration_done_supported {
if configuration_done_supported {
this.request(ConfigurationDone {})
} else {
Task::ready(Ok(()))
}
.await;
ret
.await
}
});
@ -839,7 +838,7 @@ impl Session {
})
.detach();
let this = Self {
Self {
mode: SessionState::Booting(None),
id: session_id,
child_session_ids: HashSet::default(),
@ -868,9 +867,7 @@ impl Session {
task_context,
memory: memory::Memory::new(),
quirks,
};
this
}
})
}

View file

@ -446,17 +446,14 @@ impl ImageStore {
event: &ImageItemEvent,
cx: &mut Context<Self>,
) {
match event {
ImageItemEvent::FileHandleChanged => {
if let Some(local) = self.state.as_local() {
if let ImageItemEvent::FileHandleChanged = event
&& let Some(local) = self.state.as_local()
{
local.update(cx, |local, cx| {
local.image_changed_file(image, cx);
})
}
}
_ => {}
}
}
}
impl ImageStoreImpl for Entity<LocalImageStore> {
@ -531,14 +528,11 @@ impl ImageStoreImpl for Entity<LocalImageStore> {
impl LocalImageStore {
fn subscribe_to_worktree(&mut self, worktree: &Entity<Worktree>, cx: &mut Context<Self>) {
cx.subscribe(worktree, |this, worktree, event, cx| {
if worktree.read(cx).is_local() {
match event {
worktree::Event::UpdatedEntries(changes) => {
if worktree.read(cx).is_local()
&& let worktree::Event::UpdatedEntries(changes) = event
{
this.local_worktree_entries_changed(&worktree, changes, cx);
}
_ => {}
}
}
})
.detach();
}

View file

@ -2501,8 +2501,8 @@ pub(crate) fn parse_completion_text_edit(
};
Some(ParsedCompletionEdit {
insert_range: insert_range,
replace_range: replace_range,
insert_range,
replace_range,
new_text: new_text.clone(),
})
}

View file

@ -550,7 +550,7 @@ impl LocalLspStore {
if let Some(settings) = settings.binary.as_ref() {
if let Some(arguments) = &settings.arguments {
binary.arguments = arguments.into_iter().map(Into::into).collect();
binary.arguments = arguments.iter().map(Into::into).collect();
}
if let Some(env) = &settings.env {
shell_env.extend(env.iter().map(|(k, v)| (k.clone(), v.clone())));
@ -1060,8 +1060,8 @@ impl LocalLspStore {
};
let delegate: Arc<dyn ManifestDelegate> =
Arc::new(ManifestQueryDelegate::new(worktree.read(cx).snapshot()));
let root = self
.lsp_tree
self.lsp_tree
.get(
project_path,
language.name(),
@ -1069,9 +1069,7 @@ impl LocalLspStore {
&delegate,
cx,
)
.collect::<Vec<_>>();
root
.collect::<Vec<_>>()
}
fn language_server_ids_for_buffer(
@ -2397,7 +2395,8 @@ impl LocalLspStore {
let server_id = server_node.server_id_or_init(|disposition| {
let path = &disposition.path;
let server_id = {
{
let uri =
Url::from_file_path(worktree.read(cx).abs_path().join(&path.path));
@ -2415,9 +2414,7 @@ impl LocalLspStore {
state.add_workspace_folder(uri);
};
server_id
};
server_id
}
})?;
let server_state = self.language_servers.get(&server_id)?;
if let LanguageServerState::Running {
@ -3047,16 +3044,14 @@ impl LocalLspStore {
buffer.edit([(range, text)], None, cx);
}
let transaction = buffer.end_transaction(cx).and_then(|transaction_id| {
buffer.end_transaction(cx).and_then(|transaction_id| {
if push_to_history {
buffer.finalize_last_transaction();
buffer.get_transaction(transaction_id).cloned()
} else {
buffer.forget_transaction(transaction_id)
}
});
transaction
})
})?;
if let Some(transaction) = transaction {
project_transaction.0.insert(buffer_to_edit, transaction);
@ -4370,11 +4365,9 @@ impl LspStore {
if let Some((client, downstream_project_id)) = self.downstream_client.clone()
&& let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id())
{
let mut summaries = diangostic_summaries
.into_iter()
.flat_map(|(path, summaries)| {
let mut summaries = diangostic_summaries.iter().flat_map(|(path, summaries)| {
summaries
.into_iter()
.iter()
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
});
if let Some(summary) = summaries.next() {
@ -4564,7 +4557,7 @@ impl LspStore {
anyhow::anyhow!(message)
})?;
let response = request
request
.response_from_lsp(
response,
this.upgrade().context("no app context")?,
@ -4572,8 +4565,7 @@ impl LspStore {
language_server.server_id(),
cx.clone(),
)
.await;
response
.await
})
}
@ -4853,7 +4845,7 @@ impl LspStore {
push_to_history: bool,
cx: &mut Context<Self>,
) -> Task<anyhow::Result<ProjectTransaction>> {
if let Some(_) = self.as_local() {
if self.as_local().is_some() {
cx.spawn(async move |lsp_store, cx| {
let buffers = buffers.into_iter().collect::<Vec<_>>();
let result = LocalLspStore::execute_code_action_kind_locally(
@ -7804,7 +7796,7 @@ impl LspStore {
}
None => {
diagnostics_summary = Some(proto::UpdateDiagnosticSummary {
project_id: project_id,
project_id,
worktree_id: worktree_id.to_proto(),
summary: Some(proto::DiagnosticSummary {
path: project_path.path.as_ref().to_proto(),
@ -10054,7 +10046,7 @@ impl LspStore {
cx: &mut Context<Self>,
) -> Task<anyhow::Result<ProjectTransaction>> {
let logger = zlog::scoped!("format");
if let Some(_) = self.as_local() {
if self.as_local().is_some() {
zlog::trace!(logger => "Formatting locally");
let logger = zlog::scoped!(logger => "local");
let buffers = buffers

View file

@ -43,13 +43,10 @@ impl WorktreeRoots {
match event {
WorktreeEvent::UpdatedEntries(changes) => {
for (path, _, kind) in changes.iter() {
match kind {
worktree::PathChange::Removed => {
if kind == &worktree::PathChange::Removed {
let path = TriePath::from(path.as_ref());
this.roots.remove(&path);
}
_ => {}
}
}
}
WorktreeEvent::UpdatedGitRepositories(_) => {}
@ -197,12 +194,9 @@ impl ManifestTree {
evt: &WorktreeStoreEvent,
_: &mut Context<Self>,
) {
match evt {
WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) => {
if let WorktreeStoreEvent::WorktreeRemoved(_, worktree_id) = evt {
self.root_points.remove(worktree_id);
}
_ => {}
}
}
}

Some files were not shown because too many files have changed in this diff Show more