Fix a bunch of other low-hanging style lints (#36498)
- **Fix a bunch of low hanging style lints like unnecessary-return** - **Fix single worktree violation** - **And the rest** Release Notes: - N/A
This commit is contained in:
parent
df9c2aefb1
commit
05fc0c432c
239 changed files with 854 additions and 1015 deletions
|
@ -797,7 +797,7 @@ impl MentionCompletion {
|
|||
&& line
|
||||
.chars()
|
||||
.nth(last_mention_start - 1)
|
||||
.map_or(false, |c| !c.is_whitespace())
|
||||
.is_some_and(|c| !c.is_whitespace())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -1552,14 +1552,14 @@ impl SemanticsProvider for SlashCommandSemanticsProvider {
|
|||
return None;
|
||||
}
|
||||
let range = snapshot.anchor_after(start)..snapshot.anchor_after(end);
|
||||
return Some(Task::ready(vec![project::Hover {
|
||||
Some(Task::ready(vec![project::Hover {
|
||||
contents: vec![project::HoverBlock {
|
||||
text: "Slash commands are not supported".into(),
|
||||
kind: project::HoverBlockKind::PlainText,
|
||||
}],
|
||||
range: Some(range),
|
||||
language: None,
|
||||
}]));
|
||||
}]))
|
||||
}
|
||||
|
||||
fn inline_values(
|
||||
|
|
|
@ -102,7 +102,7 @@ impl ProfileProvider for Entity<agent2::Thread> {
|
|||
fn profiles_supported(&self, cx: &App) -> bool {
|
||||
self.read(cx)
|
||||
.model()
|
||||
.map_or(false, |model| model.supports_tools())
|
||||
.is_some_and(|model| model.supports_tools())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2843,7 +2843,7 @@ impl AcpThreadView {
|
|||
|
||||
if thread
|
||||
.model()
|
||||
.map_or(true, |model| !model.supports_burn_mode())
|
||||
.is_none_or(|model| !model.supports_burn_mode())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
@ -2875,9 +2875,9 @@ impl AcpThreadView {
|
|||
|
||||
fn render_send_button(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||
let is_editor_empty = self.message_editor.read(cx).is_empty(cx);
|
||||
let is_generating = self.thread().map_or(false, |thread| {
|
||||
thread.read(cx).status() != ThreadStatus::Idle
|
||||
});
|
||||
let is_generating = self
|
||||
.thread()
|
||||
.is_some_and(|thread| thread.read(cx).status() != ThreadStatus::Idle);
|
||||
|
||||
if is_generating && is_editor_empty {
|
||||
IconButton::new("stop-generation", IconName::Stop)
|
||||
|
@ -3455,18 +3455,16 @@ impl AcpThreadView {
|
|||
} else {
|
||||
format!("Retrying. Next attempt in {next_attempt_in_secs} seconds.")
|
||||
}
|
||||
} else if next_attempt_in_secs == 1 {
|
||||
format!(
|
||||
"Retrying. Next attempt in 1 second (Attempt {} of {}).",
|
||||
state.attempt, state.max_attempts,
|
||||
)
|
||||
} else {
|
||||
if next_attempt_in_secs == 1 {
|
||||
format!(
|
||||
"Retrying. Next attempt in 1 second (Attempt {} of {}).",
|
||||
state.attempt, state.max_attempts,
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"Retrying. Next attempt in {next_attempt_in_secs} seconds (Attempt {} of {}).",
|
||||
state.attempt, state.max_attempts,
|
||||
)
|
||||
}
|
||||
format!(
|
||||
"Retrying. Next attempt in {next_attempt_in_secs} seconds (Attempt {} of {}).",
|
||||
state.attempt, state.max_attempts,
|
||||
)
|
||||
};
|
||||
|
||||
Some(
|
||||
|
@ -3552,7 +3550,7 @@ impl AcpThreadView {
|
|||
let supports_burn_mode = thread
|
||||
.read(cx)
|
||||
.model()
|
||||
.map_or(false, |model| model.supports_burn_mode());
|
||||
.is_some_and(|model| model.supports_burn_mode());
|
||||
|
||||
let focus_handle = self.focus_handle(cx);
|
||||
|
||||
|
|
|
@ -2246,9 +2246,7 @@ impl ActiveThread {
|
|||
let after_editing_message = self
|
||||
.editing_message
|
||||
.as_ref()
|
||||
.map_or(false, |(editing_message_id, _)| {
|
||||
message_id > *editing_message_id
|
||||
});
|
||||
.is_some_and(|(editing_message_id, _)| message_id > *editing_message_id);
|
||||
|
||||
let backdrop = div()
|
||||
.id(("backdrop", ix))
|
||||
|
|
|
@ -96,7 +96,7 @@ impl AgentConfiguration {
|
|||
let mut expanded_provider_configurations = HashMap::default();
|
||||
if LanguageModelRegistry::read_global(cx)
|
||||
.provider(&ZED_CLOUD_PROVIDER_ID)
|
||||
.map_or(false, |cloud_provider| cloud_provider.must_accept_terms(cx))
|
||||
.is_some_and(|cloud_provider| cloud_provider.must_accept_terms(cx))
|
||||
{
|
||||
expanded_provider_configurations.insert(ZED_CLOUD_PROVIDER_ID, true);
|
||||
}
|
||||
|
|
|
@ -285,7 +285,7 @@ impl AgentDiffPane {
|
|||
&& buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map_or(false, |file| file.disk_state() == DiskState::Deleted)
|
||||
.is_some_and(|file| file.disk_state() == DiskState::Deleted)
|
||||
{
|
||||
editor.fold_buffer(snapshot.text.remote_id(), cx)
|
||||
}
|
||||
|
@ -1063,7 +1063,7 @@ impl ToolbarItemView for AgentDiffToolbar {
|
|||
}
|
||||
|
||||
self.active_item = None;
|
||||
return self.location(cx);
|
||||
self.location(cx)
|
||||
}
|
||||
|
||||
fn pane_focus_update(
|
||||
|
@ -1509,7 +1509,7 @@ impl AgentDiff {
|
|||
.read(cx)
|
||||
.entries()
|
||||
.last()
|
||||
.map_or(false, |entry| entry.diffs().next().is_some())
|
||||
.is_some_and(|entry| entry.diffs().next().is_some())
|
||||
{
|
||||
self.update_reviewing_editors(workspace, window, cx);
|
||||
}
|
||||
|
@ -1519,7 +1519,7 @@ impl AgentDiff {
|
|||
.read(cx)
|
||||
.entries()
|
||||
.get(*ix)
|
||||
.map_or(false, |entry| entry.diffs().next().is_some())
|
||||
.is_some_and(|entry| entry.diffs().next().is_some())
|
||||
{
|
||||
self.update_reviewing_editors(workspace, window, cx);
|
||||
}
|
||||
|
@ -1709,7 +1709,7 @@ impl AgentDiff {
|
|||
.read_with(cx, |editor, _cx| editor.workspace())
|
||||
.ok()
|
||||
.flatten()
|
||||
.map_or(false, |editor_workspace| {
|
||||
.is_some_and(|editor_workspace| {
|
||||
editor_workspace.entity_id() == workspace.entity_id()
|
||||
});
|
||||
|
||||
|
@ -1868,7 +1868,7 @@ impl AgentDiff {
|
|||
}
|
||||
}
|
||||
|
||||
return Some(Task::ready(Ok(())));
|
||||
Some(Task::ready(Ok(())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1463,7 +1463,7 @@ impl AgentPanel {
|
|||
AssistantConfigurationEvent::NewThread(provider) => {
|
||||
if LanguageModelRegistry::read_global(cx)
|
||||
.default_model()
|
||||
.map_or(true, |model| model.provider.id() != provider.id())
|
||||
.is_none_or(|model| model.provider.id() != provider.id())
|
||||
&& let Some(model) = provider.default_model(cx)
|
||||
{
|
||||
update_settings_file::<AgentSettings>(
|
||||
|
@ -2708,9 +2708,7 @@ impl AgentPanel {
|
|||
}
|
||||
ActiveView::ExternalAgentThread { .. }
|
||||
| ActiveView::History
|
||||
| ActiveView::Configuration => {
|
||||
return None;
|
||||
}
|
||||
| ActiveView::Configuration => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2726,7 +2724,7 @@ impl AgentPanel {
|
|||
.thread()
|
||||
.read(cx)
|
||||
.configured_model()
|
||||
.map_or(false, |model| {
|
||||
.is_some_and(|model| {
|
||||
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
||||
})
|
||||
{
|
||||
|
@ -2737,7 +2735,7 @@ impl AgentPanel {
|
|||
if LanguageModelRegistry::global(cx)
|
||||
.read(cx)
|
||||
.default_model()
|
||||
.map_or(false, |model| {
|
||||
.is_some_and(|model| {
|
||||
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
||||
})
|
||||
{
|
||||
|
@ -3051,9 +3049,7 @@ impl AgentPanel {
|
|||
let zed_provider_configured = AgentSettings::get_global(cx)
|
||||
.default_model
|
||||
.as_ref()
|
||||
.map_or(false, |selection| {
|
||||
selection.provider.0.as_str() == "zed.dev"
|
||||
});
|
||||
.is_some_and(|selection| selection.provider.0.as_str() == "zed.dev");
|
||||
|
||||
let callout = if zed_provider_configured {
|
||||
Callout::new()
|
||||
|
|
|
@ -610,9 +610,7 @@ pub(crate) fn available_context_picker_entries(
|
|||
.read(cx)
|
||||
.active_item(cx)
|
||||
.and_then(|item| item.downcast::<Editor>())
|
||||
.map_or(false, |editor| {
|
||||
editor.update(cx, |editor, cx| editor.has_non_empty_selection(cx))
|
||||
});
|
||||
.is_some_and(|editor| editor.update(cx, |editor, cx| editor.has_non_empty_selection(cx)));
|
||||
if has_selection {
|
||||
entries.push(ContextPickerEntry::Action(
|
||||
ContextPickerAction::AddSelections,
|
||||
|
@ -680,7 +678,7 @@ pub(crate) fn recent_context_picker_entries(
|
|||
.filter(|(_, abs_path)| {
|
||||
abs_path
|
||||
.as_ref()
|
||||
.map_or(true, |path| !exclude_paths.contains(path.as_path()))
|
||||
.is_none_or(|path| !exclude_paths.contains(path.as_path()))
|
||||
})
|
||||
.take(4)
|
||||
.filter_map(|(project_path, _)| {
|
||||
|
|
|
@ -1020,7 +1020,7 @@ impl MentionCompletion {
|
|||
&& line
|
||||
.chars()
|
||||
.nth(last_mention_start - 1)
|
||||
.map_or(false, |c| !c.is_whitespace())
|
||||
.is_some_and(|c| !c.is_whitespace())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -226,9 +226,10 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
|||
_window: &mut Window,
|
||||
cx: &mut Context<Picker<Self>>,
|
||||
) -> Option<Self::ListItem> {
|
||||
let added = self.context_store.upgrade().map_or(false, |context_store| {
|
||||
context_store.read(cx).includes_url(&self.url)
|
||||
});
|
||||
let added = self
|
||||
.context_store
|
||||
.upgrade()
|
||||
.is_some_and(|context_store| context_store.read(cx).includes_url(&self.url));
|
||||
|
||||
Some(
|
||||
ListItem::new(ix)
|
||||
|
|
|
@ -239,9 +239,7 @@ pub(crate) fn search_files(
|
|||
|
||||
PathMatchCandidateSet {
|
||||
snapshot: worktree.snapshot(),
|
||||
include_ignored: worktree
|
||||
.root_entry()
|
||||
.map_or(false, |entry| entry.is_ignored),
|
||||
include_ignored: worktree.root_entry().is_some_and(|entry| entry.is_ignored),
|
||||
include_root_name: true,
|
||||
candidates: project::Candidates::Entries,
|
||||
}
|
||||
|
|
|
@ -159,7 +159,7 @@ pub fn render_thread_context_entry(
|
|||
context_store: WeakEntity<ContextStore>,
|
||||
cx: &mut App,
|
||||
) -> Div {
|
||||
let added = context_store.upgrade().map_or(false, |context_store| {
|
||||
let added = context_store.upgrade().is_some_and(|context_store| {
|
||||
context_store
|
||||
.read(cx)
|
||||
.includes_user_rules(user_rules.prompt_id)
|
||||
|
|
|
@ -294,7 +294,7 @@ pub(crate) fn search_symbols(
|
|||
.partition(|candidate| {
|
||||
project
|
||||
.entry_for_path(&symbols[candidate.id].path, cx)
|
||||
.map_or(false, |e| !e.is_ignored)
|
||||
.is_some_and(|e| !e.is_ignored)
|
||||
})
|
||||
})
|
||||
.log_err()
|
||||
|
|
|
@ -236,12 +236,10 @@ pub fn render_thread_context_entry(
|
|||
let is_added = match entry {
|
||||
ThreadContextEntry::Thread { id, .. } => context_store
|
||||
.upgrade()
|
||||
.map_or(false, |ctx_store| ctx_store.read(cx).includes_thread(id)),
|
||||
ThreadContextEntry::Context { path, .. } => {
|
||||
context_store.upgrade().map_or(false, |ctx_store| {
|
||||
ctx_store.read(cx).includes_text_thread(path)
|
||||
})
|
||||
}
|
||||
.is_some_and(|ctx_store| ctx_store.read(cx).includes_thread(id)),
|
||||
ThreadContextEntry::Context { path, .. } => context_store
|
||||
.upgrade()
|
||||
.is_some_and(|ctx_store| ctx_store.read(cx).includes_text_thread(path)),
|
||||
};
|
||||
|
||||
h_flex()
|
||||
|
|
|
@ -1120,7 +1120,7 @@ impl InlineAssistant {
|
|||
if editor_assists
|
||||
.scroll_lock
|
||||
.as_ref()
|
||||
.map_or(false, |lock| lock.assist_id == assist_id)
|
||||
.is_some_and(|lock| lock.assist_id == assist_id)
|
||||
{
|
||||
editor_assists.scroll_lock = None;
|
||||
}
|
||||
|
|
|
@ -345,7 +345,7 @@ impl<T: 'static> PromptEditor<T> {
|
|||
let prompt = self.editor.read(cx).text(cx);
|
||||
if self
|
||||
.prompt_history_ix
|
||||
.map_or(true, |ix| self.prompt_history[ix] != prompt)
|
||||
.is_none_or(|ix| self.prompt_history[ix] != prompt)
|
||||
{
|
||||
self.prompt_history_ix.take();
|
||||
self.pending_prompt = prompt;
|
||||
|
|
|
@ -156,7 +156,7 @@ impl ProfileProvider for Entity<Thread> {
|
|||
fn profiles_supported(&self, cx: &App) -> bool {
|
||||
self.read(cx)
|
||||
.configured_model()
|
||||
.map_or(false, |model| model.model.supports_tools())
|
||||
.is_some_and(|model| model.model.supports_tools())
|
||||
}
|
||||
|
||||
fn profile_id(&self, cx: &App) -> AgentProfileId {
|
||||
|
@ -1289,7 +1289,7 @@ impl MessageEditor {
|
|||
self.thread
|
||||
.read(cx)
|
||||
.configured_model()
|
||||
.map_or(false, |model| model.provider.id() == ZED_CLOUD_PROVIDER_ID)
|
||||
.is_some_and(|model| model.provider.id() == ZED_CLOUD_PROVIDER_ID)
|
||||
}
|
||||
|
||||
fn render_usage_callout(&self, line_height: Pixels, cx: &mut Context<Self>) -> Option<Div> {
|
||||
|
@ -1442,7 +1442,7 @@ impl MessageEditor {
|
|||
let message_text = editor.read(cx).text(cx);
|
||||
|
||||
if message_text.is_empty()
|
||||
&& loaded_context.map_or(true, |loaded_context| loaded_context.is_empty())
|
||||
&& loaded_context.is_none_or(|loaded_context| loaded_context.is_empty())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
|
|
@ -140,12 +140,10 @@ impl PickerDelegate for SlashCommandDelegate {
|
|||
);
|
||||
ret.push(index - 1);
|
||||
}
|
||||
} else {
|
||||
if let SlashCommandEntry::Advert { .. } = command {
|
||||
previous_is_advert = true;
|
||||
if index != 0 {
|
||||
ret.push(index - 1);
|
||||
}
|
||||
} else if let SlashCommandEntry::Advert { .. } = command {
|
||||
previous_is_advert = true;
|
||||
if index != 0 {
|
||||
ret.push(index - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ impl TextThreadEditor {
|
|||
.map(|default| default.provider);
|
||||
if provider
|
||||
.as_ref()
|
||||
.map_or(false, |provider| provider.must_accept_terms(cx))
|
||||
.is_some_and(|provider| provider.must_accept_terms(cx))
|
||||
{
|
||||
self.show_accept_terms = true;
|
||||
cx.notify();
|
||||
|
@ -457,7 +457,7 @@ impl TextThreadEditor {
|
|||
|| snapshot
|
||||
.chars_at(newest_cursor)
|
||||
.next()
|
||||
.map_or(false, |ch| ch != '\n')
|
||||
.is_some_and(|ch| ch != '\n')
|
||||
{
|
||||
editor.move_to_end_of_line(
|
||||
&MoveToEndOfLine {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue