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
|
@ -821,6 +821,7 @@ 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.
|
||||||
|
comparison_to_empty = "warn"
|
||||||
iter_cloned_collect = "warn"
|
iter_cloned_collect = "warn"
|
||||||
iter_next_slice = "warn"
|
iter_next_slice = "warn"
|
||||||
iter_nth = "warn"
|
iter_nth = "warn"
|
||||||
|
@ -831,8 +832,13 @@ question_mark = { level = "deny" }
|
||||||
redundant_closure = { level = "deny" }
|
redundant_closure = { level = "deny" }
|
||||||
declare_interior_mutable_const = { level = "deny" }
|
declare_interior_mutable_const = { level = "deny" }
|
||||||
collapsible_if = { level = "warn"}
|
collapsible_if = { level = "warn"}
|
||||||
|
collapsible_else_if = { level = "warn" }
|
||||||
needless_borrow = { level = "warn"}
|
needless_borrow = { level = "warn"}
|
||||||
|
needless_return = { level = "warn" }
|
||||||
unnecessary_mut_passed = {level = "warn"}
|
unnecessary_mut_passed = {level = "warn"}
|
||||||
|
unnecessary_map_or = { level = "warn" }
|
||||||
|
unused_unit = "warn"
|
||||||
|
|
||||||
# Individual rules that have violations in the codebase:
|
# Individual rules that have violations in the codebase:
|
||||||
type_complexity = "allow"
|
type_complexity = "allow"
|
||||||
# We often return trait objects from `new` functions.
|
# We often return trait objects from `new` functions.
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl UserMessage {
|
||||||
if self
|
if self
|
||||||
.checkpoint
|
.checkpoint
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |checkpoint| checkpoint.show)
|
.is_some_and(|checkpoint| checkpoint.show)
|
||||||
{
|
{
|
||||||
writeln!(markdown, "## User (checkpoint)").unwrap();
|
writeln!(markdown, "## User (checkpoint)").unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -79,12 +79,10 @@ impl MentionUri {
|
||||||
} else {
|
} else {
|
||||||
Ok(Self::Selection { path, line_range })
|
Ok(Self::Selection { path, line_range })
|
||||||
}
|
}
|
||||||
|
} else if input.ends_with("/") {
|
||||||
|
Ok(Self::Directory { abs_path: path })
|
||||||
} else {
|
} else {
|
||||||
if input.ends_with("/") {
|
Ok(Self::File { abs_path: path })
|
||||||
Ok(Self::Directory { abs_path: path })
|
|
||||||
} else {
|
|
||||||
Ok(Self::File { abs_path: path })
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"zed" => {
|
"zed" => {
|
||||||
|
|
|
@ -116,7 +116,7 @@ impl ActionLog {
|
||||||
} else if buffer
|
} else if buffer
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.file()
|
.file()
|
||||||
.map_or(false, |file| file.disk_state().exists())
|
.is_some_and(|file| file.disk_state().exists())
|
||||||
{
|
{
|
||||||
TrackedBufferStatus::Created {
|
TrackedBufferStatus::Created {
|
||||||
existing_file_content: Some(buffer.read(cx).as_rope().clone()),
|
existing_file_content: Some(buffer.read(cx).as_rope().clone()),
|
||||||
|
@ -215,7 +215,7 @@ impl ActionLog {
|
||||||
if buffer
|
if buffer
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.file()
|
.file()
|
||||||
.map_or(false, |file| file.disk_state() == DiskState::Deleted)
|
.is_some_and(|file| file.disk_state() == DiskState::Deleted)
|
||||||
{
|
{
|
||||||
// If the buffer had been edited by a tool, but it got
|
// If the buffer had been edited by a tool, but it got
|
||||||
// deleted externally, we want to stop tracking it.
|
// deleted externally, we want to stop tracking it.
|
||||||
|
@ -227,7 +227,7 @@ impl ActionLog {
|
||||||
if buffer
|
if buffer
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.file()
|
.file()
|
||||||
.map_or(false, |file| file.disk_state() != DiskState::Deleted)
|
.is_some_and(|file| file.disk_state() != DiskState::Deleted)
|
||||||
{
|
{
|
||||||
// If the buffer had been deleted by a tool, but it got
|
// If the buffer had been deleted by a tool, but it got
|
||||||
// resurrected externally, we want to clear the edits we
|
// resurrected externally, we want to clear the edits we
|
||||||
|
@ -811,7 +811,7 @@ impl ActionLog {
|
||||||
tracked.version != buffer.version
|
tracked.version != buffer.version
|
||||||
&& buffer
|
&& buffer
|
||||||
.file()
|
.file()
|
||||||
.map_or(false, |file| file.disk_state() != DiskState::Deleted)
|
.is_some_and(|file| file.disk_state() != DiskState::Deleted)
|
||||||
})
|
})
|
||||||
.map(|(buffer, _)| buffer)
|
.map(|(buffer, _)| buffer)
|
||||||
}
|
}
|
||||||
|
@ -847,7 +847,7 @@ fn apply_non_conflicting_edits(
|
||||||
conflict = true;
|
conflict = true;
|
||||||
if new_edits
|
if new_edits
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |next_edit| next_edit.old.overlaps(&old_edit.new))
|
.is_some_and(|next_edit| next_edit.old.overlaps(&old_edit.new))
|
||||||
{
|
{
|
||||||
new_edit = new_edits.next().unwrap();
|
new_edit = new_edits.next().unwrap();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -90,7 +90,7 @@ impl AgentProfile {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
return Self::is_enabled(settings, source, tool_name);
|
Self::is_enabled(settings, source, tool_name)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_enabled(settings: &AgentProfileSettings, source: ToolSource, name: String) -> bool {
|
fn is_enabled(settings: &AgentProfileSettings, source: ToolSource, name: String) -> bool {
|
||||||
|
|
|
@ -42,7 +42,7 @@ use std::{
|
||||||
use util::ResultExt as _;
|
use util::ResultExt as _;
|
||||||
|
|
||||||
pub static ZED_STATELESS: std::sync::LazyLock<bool> =
|
pub static ZED_STATELESS: std::sync::LazyLock<bool> =
|
||||||
std::sync::LazyLock::new(|| std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty()));
|
std::sync::LazyLock::new(|| std::env::var("ZED_STATELESS").is_ok_and(|v| !v.is_empty()));
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum DataType {
|
pub enum DataType {
|
||||||
|
|
|
@ -275,7 +275,7 @@ impl ToolUseState {
|
||||||
pub fn message_has_tool_results(&self, assistant_message_id: MessageId) -> bool {
|
pub fn message_has_tool_results(&self, assistant_message_id: MessageId) -> bool {
|
||||||
self.tool_uses_by_assistant_message
|
self.tool_uses_by_assistant_message
|
||||||
.get(&assistant_message_id)
|
.get(&assistant_message_id)
|
||||||
.map_or(false, |results| !results.is_empty())
|
.is_some_and(|results| !results.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn tool_result(
|
pub fn tool_result(
|
||||||
|
|
|
@ -184,7 +184,7 @@ impl DbThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static ZED_STATELESS: std::sync::LazyLock<bool> =
|
pub static ZED_STATELESS: std::sync::LazyLock<bool> =
|
||||||
std::sync::LazyLock::new(|| std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty()));
|
std::sync::LazyLock::new(|| std::env::var("ZED_STATELESS").is_ok_and(|v| !v.is_empty()));
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum DataType {
|
pub enum DataType {
|
||||||
|
|
|
@ -742,7 +742,7 @@ async fn expect_tool_call(events: &mut UnboundedReceiver<Result<ThreadEvent>>) -
|
||||||
.expect("no tool call authorization event received")
|
.expect("no tool call authorization event received")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match event {
|
match event {
|
||||||
ThreadEvent::ToolCall(tool_call) => return tool_call,
|
ThreadEvent::ToolCall(tool_call) => tool_call,
|
||||||
event => {
|
event => {
|
||||||
panic!("Unexpected event {event:?}");
|
panic!("Unexpected event {event:?}");
|
||||||
}
|
}
|
||||||
|
@ -758,9 +758,7 @@ async fn expect_tool_call_update_fields(
|
||||||
.expect("no tool call authorization event received")
|
.expect("no tool call authorization event received")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
match event {
|
match event {
|
||||||
ThreadEvent::ToolCallUpdate(acp_thread::ToolCallUpdate::UpdateFields(update)) => {
|
ThreadEvent::ToolCallUpdate(acp_thread::ToolCallUpdate::UpdateFields(update)) => update,
|
||||||
return update;
|
|
||||||
}
|
|
||||||
event => {
|
event => {
|
||||||
panic!("Unexpected event {event:?}");
|
panic!("Unexpected event {event:?}");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1356,7 +1356,7 @@ impl Thread {
|
||||||
|
|
||||||
// Ensure the last message ends in the current tool use
|
// Ensure the last message ends in the current tool use
|
||||||
let last_message = self.pending_message();
|
let last_message = self.pending_message();
|
||||||
let push_new_tool_use = last_message.content.last_mut().map_or(true, |content| {
|
let push_new_tool_use = last_message.content.last_mut().is_none_or(|content| {
|
||||||
if let AgentMessageContent::ToolUse(last_tool_use) = content {
|
if let AgentMessageContent::ToolUse(last_tool_use) = content {
|
||||||
if last_tool_use.id == tool_use.id {
|
if last_tool_use.id == tool_use.id {
|
||||||
*last_tool_use = tool_use.clone();
|
*last_tool_use = tool_use.clone();
|
||||||
|
@ -1408,7 +1408,7 @@ impl Thread {
|
||||||
status: Some(acp::ToolCallStatus::InProgress),
|
status: Some(acp::ToolCallStatus::InProgress),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
let supports_images = self.model().map_or(false, |model| model.supports_images());
|
let supports_images = self.model().is_some_and(|model| model.supports_images());
|
||||||
let tool_result = tool.run(tool_use.input, tool_event_stream, cx);
|
let tool_result = tool.run(tool_use.input, tool_event_stream, cx);
|
||||||
log::info!("Running tool {}", tool_use.name);
|
log::info!("Running tool {}", tool_use.name);
|
||||||
Some(cx.foreground_executor().spawn(async move {
|
Some(cx.foreground_executor().spawn(async move {
|
||||||
|
|
|
@ -175,7 +175,7 @@ impl AgentTool for ReadFileTool {
|
||||||
buffer
|
buffer
|
||||||
.file()
|
.file()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |file| !file.disk_state().exists())
|
.is_none_or(|file| !file.disk_state().exists())
|
||||||
})? {
|
})? {
|
||||||
anyhow::bail!("{file_path} not found");
|
anyhow::bail!("{file_path} not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,7 +271,7 @@ fn working_dir(
|
||||||
let project = project.read(cx);
|
let project = project.read(cx);
|
||||||
let cd = &input.cd;
|
let cd = &input.cd;
|
||||||
|
|
||||||
if cd == "." || cd == "" {
|
if cd == "." || cd.is_empty() {
|
||||||
// Accept "." or "" as meaning "the one worktree" if we only have one worktree.
|
// Accept "." or "" as meaning "the one worktree" if we only have one worktree.
|
||||||
let mut worktrees = project.worktrees(cx);
|
let mut worktrees = project.worktrees(cx);
|
||||||
|
|
||||||
|
@ -296,10 +296,8 @@ fn working_dir(
|
||||||
{
|
{
|
||||||
return Ok(Some(input_path.into()));
|
return Ok(Some(input_path.into()));
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(worktree) = project.worktree_for_root_name(cd, cx) {
|
||||||
if let Some(worktree) = project.worktree_for_root_name(cd, cx) {
|
return Ok(Some(worktree.read(cx).abs_path().to_path_buf()));
|
||||||
return Ok(Some(worktree.read(cx).abs_path().to_path_buf()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anyhow::bail!("`cd` directory {cd:?} was not in any of the project's worktrees.");
|
anyhow::bail!("`cd` directory {cd:?} was not in any of the project's worktrees.");
|
||||||
|
|
|
@ -104,7 +104,7 @@ impl AgentServerCommand {
|
||||||
cx: &mut AsyncApp,
|
cx: &mut AsyncApp,
|
||||||
) -> Option<Self> {
|
) -> Option<Self> {
|
||||||
if let Some(agent_settings) = settings {
|
if let Some(agent_settings) = settings {
|
||||||
return Some(Self {
|
Some(Self {
|
||||||
path: agent_settings.command.path,
|
path: agent_settings.command.path,
|
||||||
args: agent_settings
|
args: agent_settings
|
||||||
.command
|
.command
|
||||||
|
@ -113,7 +113,7 @@ impl AgentServerCommand {
|
||||||
.chain(extra_args.iter().map(|arg| arg.to_string()))
|
.chain(extra_args.iter().map(|arg| arg.to_string()))
|
||||||
.collect(),
|
.collect(),
|
||||||
env: agent_settings.command.env,
|
env: agent_settings.command.env,
|
||||||
});
|
})
|
||||||
} else {
|
} else {
|
||||||
match find_bin_in_path(path_bin_name, project, cx).await {
|
match find_bin_in_path(path_bin_name, project, cx).await {
|
||||||
Some(path) => Some(Self {
|
Some(path) => Some(Self {
|
||||||
|
|
|
@ -471,7 +471,7 @@ pub fn get_zed_path() -> PathBuf {
|
||||||
|
|
||||||
while zed_path
|
while zed_path
|
||||||
.file_name()
|
.file_name()
|
||||||
.map_or(true, |name| name.to_string_lossy() != "debug")
|
.is_none_or(|name| name.to_string_lossy() != "debug")
|
||||||
{
|
{
|
||||||
if !zed_path.pop() {
|
if !zed_path.pop() {
|
||||||
panic!("Could not find target directory");
|
panic!("Could not find target directory");
|
||||||
|
|
|
@ -58,7 +58,7 @@ impl AgentProfileSettings {
|
||||||
|| self
|
|| self
|
||||||
.context_servers
|
.context_servers
|
||||||
.get(server_id)
|
.get(server_id)
|
||||||
.map_or(false, |preset| preset.tools.get(tool_name) == Some(&true))
|
.is_some_and(|preset| preset.tools.get(tool_name) == Some(&true))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -797,7 +797,7 @@ impl MentionCompletion {
|
||||||
&& line
|
&& line
|
||||||
.chars()
|
.chars()
|
||||||
.nth(last_mention_start - 1)
|
.nth(last_mention_start - 1)
|
||||||
.map_or(false, |c| !c.is_whitespace())
|
.is_some_and(|c| !c.is_whitespace())
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1552,14 +1552,14 @@ impl SemanticsProvider for SlashCommandSemanticsProvider {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let range = snapshot.anchor_after(start)..snapshot.anchor_after(end);
|
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 {
|
contents: vec![project::HoverBlock {
|
||||||
text: "Slash commands are not supported".into(),
|
text: "Slash commands are not supported".into(),
|
||||||
kind: project::HoverBlockKind::PlainText,
|
kind: project::HoverBlockKind::PlainText,
|
||||||
}],
|
}],
|
||||||
range: Some(range),
|
range: Some(range),
|
||||||
language: None,
|
language: None,
|
||||||
}]));
|
}]))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inline_values(
|
fn inline_values(
|
||||||
|
|
|
@ -102,7 +102,7 @@ impl ProfileProvider for Entity<agent2::Thread> {
|
||||||
fn profiles_supported(&self, cx: &App) -> bool {
|
fn profiles_supported(&self, cx: &App) -> bool {
|
||||||
self.read(cx)
|
self.read(cx)
|
||||||
.model()
|
.model()
|
||||||
.map_or(false, |model| model.supports_tools())
|
.is_some_and(|model| model.supports_tools())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2843,7 +2843,7 @@ impl AcpThreadView {
|
||||||
|
|
||||||
if thread
|
if thread
|
||||||
.model()
|
.model()
|
||||||
.map_or(true, |model| !model.supports_burn_mode())
|
.is_none_or(|model| !model.supports_burn_mode())
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -2875,9 +2875,9 @@ impl AcpThreadView {
|
||||||
|
|
||||||
fn render_send_button(&self, cx: &mut Context<Self>) -> AnyElement {
|
fn render_send_button(&self, cx: &mut Context<Self>) -> AnyElement {
|
||||||
let is_editor_empty = self.message_editor.read(cx).is_empty(cx);
|
let is_editor_empty = self.message_editor.read(cx).is_empty(cx);
|
||||||
let is_generating = self.thread().map_or(false, |thread| {
|
let is_generating = self
|
||||||
thread.read(cx).status() != ThreadStatus::Idle
|
.thread()
|
||||||
});
|
.is_some_and(|thread| thread.read(cx).status() != ThreadStatus::Idle);
|
||||||
|
|
||||||
if is_generating && is_editor_empty {
|
if is_generating && is_editor_empty {
|
||||||
IconButton::new("stop-generation", IconName::Stop)
|
IconButton::new("stop-generation", IconName::Stop)
|
||||||
|
@ -3455,18 +3455,16 @@ impl AcpThreadView {
|
||||||
} else {
|
} else {
|
||||||
format!("Retrying. Next attempt in {next_attempt_in_secs} seconds.")
|
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 {
|
} else {
|
||||||
if next_attempt_in_secs == 1 {
|
format!(
|
||||||
format!(
|
"Retrying. Next attempt in {next_attempt_in_secs} seconds (Attempt {} of {}).",
|
||||||
"Retrying. Next attempt in 1 second (Attempt {} of {}).",
|
state.attempt, state.max_attempts,
|
||||||
state.attempt, state.max_attempts,
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
format!(
|
|
||||||
"Retrying. Next attempt in {next_attempt_in_secs} seconds (Attempt {} of {}).",
|
|
||||||
state.attempt, state.max_attempts,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
|
@ -3552,7 +3550,7 @@ impl AcpThreadView {
|
||||||
let supports_burn_mode = thread
|
let supports_burn_mode = thread
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.model()
|
.model()
|
||||||
.map_or(false, |model| model.supports_burn_mode());
|
.is_some_and(|model| model.supports_burn_mode());
|
||||||
|
|
||||||
let focus_handle = self.focus_handle(cx);
|
let focus_handle = self.focus_handle(cx);
|
||||||
|
|
||||||
|
|
|
@ -2246,9 +2246,7 @@ impl ActiveThread {
|
||||||
let after_editing_message = self
|
let after_editing_message = self
|
||||||
.editing_message
|
.editing_message
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |(editing_message_id, _)| {
|
.is_some_and(|(editing_message_id, _)| message_id > *editing_message_id);
|
||||||
message_id > *editing_message_id
|
|
||||||
});
|
|
||||||
|
|
||||||
let backdrop = div()
|
let backdrop = div()
|
||||||
.id(("backdrop", ix))
|
.id(("backdrop", ix))
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl AgentConfiguration {
|
||||||
let mut expanded_provider_configurations = HashMap::default();
|
let mut expanded_provider_configurations = HashMap::default();
|
||||||
if LanguageModelRegistry::read_global(cx)
|
if LanguageModelRegistry::read_global(cx)
|
||||||
.provider(&ZED_CLOUD_PROVIDER_ID)
|
.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);
|
expanded_provider_configurations.insert(ZED_CLOUD_PROVIDER_ID, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,7 +285,7 @@ impl AgentDiffPane {
|
||||||
&& buffer
|
&& buffer
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.file()
|
.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)
|
editor.fold_buffer(snapshot.text.remote_id(), cx)
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1063,7 @@ impl ToolbarItemView for AgentDiffToolbar {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.active_item = None;
|
self.active_item = None;
|
||||||
return self.location(cx);
|
self.location(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pane_focus_update(
|
fn pane_focus_update(
|
||||||
|
@ -1509,7 +1509,7 @@ impl AgentDiff {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.entries()
|
.entries()
|
||||||
.last()
|
.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);
|
self.update_reviewing_editors(workspace, window, cx);
|
||||||
}
|
}
|
||||||
|
@ -1519,7 +1519,7 @@ impl AgentDiff {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.entries()
|
.entries()
|
||||||
.get(*ix)
|
.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);
|
self.update_reviewing_editors(workspace, window, cx);
|
||||||
}
|
}
|
||||||
|
@ -1709,7 +1709,7 @@ impl AgentDiff {
|
||||||
.read_with(cx, |editor, _cx| editor.workspace())
|
.read_with(cx, |editor, _cx| editor.workspace())
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
.map_or(false, |editor_workspace| {
|
.is_some_and(|editor_workspace| {
|
||||||
editor_workspace.entity_id() == workspace.entity_id()
|
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) => {
|
AssistantConfigurationEvent::NewThread(provider) => {
|
||||||
if LanguageModelRegistry::read_global(cx)
|
if LanguageModelRegistry::read_global(cx)
|
||||||
.default_model()
|
.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)
|
&& let Some(model) = provider.default_model(cx)
|
||||||
{
|
{
|
||||||
update_settings_file::<AgentSettings>(
|
update_settings_file::<AgentSettings>(
|
||||||
|
@ -2708,9 +2708,7 @@ impl AgentPanel {
|
||||||
}
|
}
|
||||||
ActiveView::ExternalAgentThread { .. }
|
ActiveView::ExternalAgentThread { .. }
|
||||||
| ActiveView::History
|
| ActiveView::History
|
||||||
| ActiveView::Configuration => {
|
| ActiveView::Configuration => None,
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2726,7 +2724,7 @@ impl AgentPanel {
|
||||||
.thread()
|
.thread()
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.configured_model()
|
.configured_model()
|
||||||
.map_or(false, |model| {
|
.is_some_and(|model| {
|
||||||
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -2737,7 +2735,7 @@ impl AgentPanel {
|
||||||
if LanguageModelRegistry::global(cx)
|
if LanguageModelRegistry::global(cx)
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.default_model()
|
.default_model()
|
||||||
.map_or(false, |model| {
|
.is_some_and(|model| {
|
||||||
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
model.provider.id() != language_model::ZED_CLOUD_PROVIDER_ID
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -3051,9 +3049,7 @@ impl AgentPanel {
|
||||||
let zed_provider_configured = AgentSettings::get_global(cx)
|
let zed_provider_configured = AgentSettings::get_global(cx)
|
||||||
.default_model
|
.default_model
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |selection| {
|
.is_some_and(|selection| selection.provider.0.as_str() == "zed.dev");
|
||||||
selection.provider.0.as_str() == "zed.dev"
|
|
||||||
});
|
|
||||||
|
|
||||||
let callout = if zed_provider_configured {
|
let callout = if zed_provider_configured {
|
||||||
Callout::new()
|
Callout::new()
|
||||||
|
|
|
@ -610,9 +610,7 @@ pub(crate) fn available_context_picker_entries(
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.active_item(cx)
|
.active_item(cx)
|
||||||
.and_then(|item| item.downcast::<Editor>())
|
.and_then(|item| item.downcast::<Editor>())
|
||||||
.map_or(false, |editor| {
|
.is_some_and(|editor| editor.update(cx, |editor, cx| editor.has_non_empty_selection(cx)));
|
||||||
editor.update(cx, |editor, cx| editor.has_non_empty_selection(cx))
|
|
||||||
});
|
|
||||||
if has_selection {
|
if has_selection {
|
||||||
entries.push(ContextPickerEntry::Action(
|
entries.push(ContextPickerEntry::Action(
|
||||||
ContextPickerAction::AddSelections,
|
ContextPickerAction::AddSelections,
|
||||||
|
@ -680,7 +678,7 @@ pub(crate) fn recent_context_picker_entries(
|
||||||
.filter(|(_, abs_path)| {
|
.filter(|(_, abs_path)| {
|
||||||
abs_path
|
abs_path
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |path| !exclude_paths.contains(path.as_path()))
|
.is_none_or(|path| !exclude_paths.contains(path.as_path()))
|
||||||
})
|
})
|
||||||
.take(4)
|
.take(4)
|
||||||
.filter_map(|(project_path, _)| {
|
.filter_map(|(project_path, _)| {
|
||||||
|
|
|
@ -1020,7 +1020,7 @@ impl MentionCompletion {
|
||||||
&& line
|
&& line
|
||||||
.chars()
|
.chars()
|
||||||
.nth(last_mention_start - 1)
|
.nth(last_mention_start - 1)
|
||||||
.map_or(false, |c| !c.is_whitespace())
|
.is_some_and(|c| !c.is_whitespace())
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -226,9 +226,10 @@ impl PickerDelegate for FetchContextPickerDelegate {
|
||||||
_window: &mut Window,
|
_window: &mut Window,
|
||||||
cx: &mut Context<Picker<Self>>,
|
cx: &mut Context<Picker<Self>>,
|
||||||
) -> Option<Self::ListItem> {
|
) -> Option<Self::ListItem> {
|
||||||
let added = self.context_store.upgrade().map_or(false, |context_store| {
|
let added = self
|
||||||
context_store.read(cx).includes_url(&self.url)
|
.context_store
|
||||||
});
|
.upgrade()
|
||||||
|
.is_some_and(|context_store| context_store.read(cx).includes_url(&self.url));
|
||||||
|
|
||||||
Some(
|
Some(
|
||||||
ListItem::new(ix)
|
ListItem::new(ix)
|
||||||
|
|
|
@ -239,9 +239,7 @@ pub(crate) fn search_files(
|
||||||
|
|
||||||
PathMatchCandidateSet {
|
PathMatchCandidateSet {
|
||||||
snapshot: worktree.snapshot(),
|
snapshot: worktree.snapshot(),
|
||||||
include_ignored: worktree
|
include_ignored: worktree.root_entry().is_some_and(|entry| entry.is_ignored),
|
||||||
.root_entry()
|
|
||||||
.map_or(false, |entry| entry.is_ignored),
|
|
||||||
include_root_name: true,
|
include_root_name: true,
|
||||||
candidates: project::Candidates::Entries,
|
candidates: project::Candidates::Entries,
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ pub fn render_thread_context_entry(
|
||||||
context_store: WeakEntity<ContextStore>,
|
context_store: WeakEntity<ContextStore>,
|
||||||
cx: &mut App,
|
cx: &mut App,
|
||||||
) -> Div {
|
) -> Div {
|
||||||
let added = context_store.upgrade().map_or(false, |context_store| {
|
let added = context_store.upgrade().is_some_and(|context_store| {
|
||||||
context_store
|
context_store
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.includes_user_rules(user_rules.prompt_id)
|
.includes_user_rules(user_rules.prompt_id)
|
||||||
|
|
|
@ -294,7 +294,7 @@ pub(crate) fn search_symbols(
|
||||||
.partition(|candidate| {
|
.partition(|candidate| {
|
||||||
project
|
project
|
||||||
.entry_for_path(&symbols[candidate.id].path, cx)
|
.entry_for_path(&symbols[candidate.id].path, cx)
|
||||||
.map_or(false, |e| !e.is_ignored)
|
.is_some_and(|e| !e.is_ignored)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.log_err()
|
.log_err()
|
||||||
|
|
|
@ -236,12 +236,10 @@ pub fn render_thread_context_entry(
|
||||||
let is_added = match entry {
|
let is_added = match entry {
|
||||||
ThreadContextEntry::Thread { id, .. } => context_store
|
ThreadContextEntry::Thread { id, .. } => context_store
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.map_or(false, |ctx_store| ctx_store.read(cx).includes_thread(id)),
|
.is_some_and(|ctx_store| ctx_store.read(cx).includes_thread(id)),
|
||||||
ThreadContextEntry::Context { path, .. } => {
|
ThreadContextEntry::Context { path, .. } => context_store
|
||||||
context_store.upgrade().map_or(false, |ctx_store| {
|
.upgrade()
|
||||||
ctx_store.read(cx).includes_text_thread(path)
|
.is_some_and(|ctx_store| ctx_store.read(cx).includes_text_thread(path)),
|
||||||
})
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
|
|
|
@ -1120,7 +1120,7 @@ impl InlineAssistant {
|
||||||
if editor_assists
|
if editor_assists
|
||||||
.scroll_lock
|
.scroll_lock
|
||||||
.as_ref()
|
.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;
|
editor_assists.scroll_lock = None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@ impl<T: 'static> PromptEditor<T> {
|
||||||
let prompt = self.editor.read(cx).text(cx);
|
let prompt = self.editor.read(cx).text(cx);
|
||||||
if self
|
if self
|
||||||
.prompt_history_ix
|
.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.prompt_history_ix.take();
|
||||||
self.pending_prompt = prompt;
|
self.pending_prompt = prompt;
|
||||||
|
|
|
@ -156,7 +156,7 @@ impl ProfileProvider for Entity<Thread> {
|
||||||
fn profiles_supported(&self, cx: &App) -> bool {
|
fn profiles_supported(&self, cx: &App) -> bool {
|
||||||
self.read(cx)
|
self.read(cx)
|
||||||
.configured_model()
|
.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 {
|
fn profile_id(&self, cx: &App) -> AgentProfileId {
|
||||||
|
@ -1289,7 +1289,7 @@ impl MessageEditor {
|
||||||
self.thread
|
self.thread
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.configured_model()
|
.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> {
|
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);
|
let message_text = editor.read(cx).text(cx);
|
||||||
|
|
||||||
if message_text.is_empty()
|
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;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,12 +140,10 @@ impl PickerDelegate for SlashCommandDelegate {
|
||||||
);
|
);
|
||||||
ret.push(index - 1);
|
ret.push(index - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else if let SlashCommandEntry::Advert { .. } = command {
|
||||||
if let SlashCommandEntry::Advert { .. } = command {
|
previous_is_advert = true;
|
||||||
previous_is_advert = true;
|
if index != 0 {
|
||||||
if index != 0 {
|
ret.push(index - 1);
|
||||||
ret.push(index - 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,7 +373,7 @@ impl TextThreadEditor {
|
||||||
.map(|default| default.provider);
|
.map(|default| default.provider);
|
||||||
if provider
|
if provider
|
||||||
.as_ref()
|
.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;
|
self.show_accept_terms = true;
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
@ -457,7 +457,7 @@ impl TextThreadEditor {
|
||||||
|| snapshot
|
|| snapshot
|
||||||
.chars_at(newest_cursor)
|
.chars_at(newest_cursor)
|
||||||
.next()
|
.next()
|
||||||
.map_or(false, |ch| ch != '\n')
|
.is_some_and(|ch| ch != '\n')
|
||||||
{
|
{
|
||||||
editor.move_to_end_of_line(
|
editor.move_to_end_of_line(
|
||||||
&MoveToEndOfLine {
|
&MoveToEndOfLine {
|
||||||
|
|
|
@ -177,11 +177,11 @@ impl AskPassSession {
|
||||||
_ = askpass_opened_rx.fuse() => {
|
_ = askpass_opened_rx.fuse() => {
|
||||||
// Note: this await can only resolve after we are dropped.
|
// Note: this await can only resolve after we are dropped.
|
||||||
askpass_kill_master_rx.await.ok();
|
askpass_kill_master_rx.await.ok();
|
||||||
return AskPassResult::CancelledByUser
|
AskPassResult::CancelledByUser
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = futures::FutureExt::fuse(smol::Timer::after(connection_timeout)) => {
|
_ = futures::FutureExt::fuse(smol::Timer::after(connection_timeout)) => {
|
||||||
return AskPassResult::Timedout
|
AskPassResult::Timedout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ pub fn main(socket: &str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
while buffer.last().map_or(false, |&b| b == b'\n' || b == b'\r') {
|
while buffer.last().is_some_and(|&b| b == b'\n' || b == b'\r') {
|
||||||
buffer.pop();
|
buffer.pop();
|
||||||
}
|
}
|
||||||
if buffer.last() != Some(&b'\0') {
|
if buffer.last() != Some(&b'\0') {
|
||||||
|
|
|
@ -1023,9 +1023,11 @@ impl AssistantContext {
|
||||||
summary: new_summary,
|
summary: new_summary,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if self.summary.timestamp().map_or(true, |current_timestamp| {
|
if self
|
||||||
new_summary.timestamp > current_timestamp
|
.summary
|
||||||
}) {
|
.timestamp()
|
||||||
|
.is_none_or(|current_timestamp| new_summary.timestamp > current_timestamp)
|
||||||
|
{
|
||||||
self.summary = ContextSummary::Content(new_summary);
|
self.summary = ContextSummary::Content(new_summary);
|
||||||
summary_generated = true;
|
summary_generated = true;
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1341,7 @@ impl AssistantContext {
|
||||||
let is_invalid = self
|
let is_invalid = self
|
||||||
.messages_metadata
|
.messages_metadata
|
||||||
.get(&message_id)
|
.get(&message_id)
|
||||||
.map_or(true, |metadata| {
|
.is_none_or(|metadata| {
|
||||||
!metadata.is_cache_valid(&buffer, &message.offset_range)
|
!metadata.is_cache_valid(&buffer, &message.offset_range)
|
||||||
|| *encountered_invalid
|
|| *encountered_invalid
|
||||||
});
|
});
|
||||||
|
@ -1860,7 +1862,7 @@ impl AssistantContext {
|
||||||
{
|
{
|
||||||
let newline_offset = insert_position.saturating_sub(1);
|
let newline_offset = insert_position.saturating_sub(1);
|
||||||
if buffer.contains_str_at(newline_offset, "\n")
|
if buffer.contains_str_at(newline_offset, "\n")
|
||||||
&& last_section_range.map_or(true, |last_section_range| {
|
&& last_section_range.is_none_or(|last_section_range| {
|
||||||
!last_section_range
|
!last_section_range
|
||||||
.to_offset(buffer)
|
.to_offset(buffer)
|
||||||
.contains(&newline_offset)
|
.contains(&newline_offset)
|
||||||
|
@ -2313,10 +2315,7 @@ impl AssistantContext {
|
||||||
let mut request_message = LanguageModelRequestMessage {
|
let mut request_message = LanguageModelRequestMessage {
|
||||||
role: message.role,
|
role: message.role,
|
||||||
content: Vec::new(),
|
content: Vec::new(),
|
||||||
cache: message
|
cache: message.cache.as_ref().is_some_and(|cache| cache.is_anchor),
|
||||||
.cache
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |cache| cache.is_anchor),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while let Some(content) = contents.peek() {
|
while let Some(content) = contents.peek() {
|
||||||
|
@ -2797,7 +2796,7 @@ impl AssistantContext {
|
||||||
let mut current_message = messages.next();
|
let mut current_message = messages.next();
|
||||||
while let Some(offset) = offsets.next() {
|
while let Some(offset) = offsets.next() {
|
||||||
// Locate the message that contains the offset.
|
// Locate the message that contains the offset.
|
||||||
while current_message.as_ref().map_or(false, |message| {
|
while current_message.as_ref().is_some_and(|message| {
|
||||||
!message.offset_range.contains(&offset) && messages.peek().is_some()
|
!message.offset_range.contains(&offset) && messages.peek().is_some()
|
||||||
}) {
|
}) {
|
||||||
current_message = messages.next();
|
current_message = messages.next();
|
||||||
|
@ -2807,7 +2806,7 @@ impl AssistantContext {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Skip offsets that are in the same message.
|
// Skip offsets that are in the same message.
|
||||||
while offsets.peek().map_or(false, |offset| {
|
while offsets.peek().is_some_and(|offset| {
|
||||||
message.offset_range.contains(offset) || messages.peek().is_none()
|
message.offset_range.contains(offset) || messages.peek().is_none()
|
||||||
}) {
|
}) {
|
||||||
offsets.next();
|
offsets.next();
|
||||||
|
|
|
@ -1055,7 +1055,7 @@ fn test_mark_cache_anchors(cx: &mut App) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
messages_cache(&context, cx)
|
messages_cache(&context, cx)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, cache)| cache.as_ref().map_or(false, |cache| cache.is_anchor))
|
.filter(|(_, cache)| cache.as_ref().is_some_and(|cache| cache.is_anchor))
|
||||||
.count(),
|
.count(),
|
||||||
0,
|
0,
|
||||||
"Empty messages should not have any cache anchors."
|
"Empty messages should not have any cache anchors."
|
||||||
|
@ -1083,7 +1083,7 @@ fn test_mark_cache_anchors(cx: &mut App) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
messages_cache(&context, cx)
|
messages_cache(&context, cx)
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|(_, cache)| cache.as_ref().map_or(false, |cache| cache.is_anchor))
|
.filter(|(_, cache)| cache.as_ref().is_some_and(|cache| cache.is_anchor))
|
||||||
.count(),
|
.count(),
|
||||||
0,
|
0,
|
||||||
"Messages should not be marked for cache before going over the token minimum."
|
"Messages should not be marked for cache before going over the token minimum."
|
||||||
|
@ -1098,7 +1098,7 @@ fn test_mark_cache_anchors(cx: &mut App) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
messages_cache(&context, cx)
|
messages_cache(&context, cx)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, cache)| cache.as_ref().map_or(false, |cache| cache.is_anchor))
|
.map(|(_, cache)| cache.as_ref().is_some_and(|cache| cache.is_anchor))
|
||||||
.collect::<Vec<bool>>(),
|
.collect::<Vec<bool>>(),
|
||||||
vec![true, true, false],
|
vec![true, true, false],
|
||||||
"Last message should not be an anchor on speculative request."
|
"Last message should not be an anchor on speculative request."
|
||||||
|
@ -1116,7 +1116,7 @@ fn test_mark_cache_anchors(cx: &mut App) {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
messages_cache(&context, cx)
|
messages_cache(&context, cx)
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_, cache)| cache.as_ref().map_or(false, |cache| cache.is_anchor))
|
.map(|(_, cache)| cache.as_ref().is_some_and(|cache| cache.is_anchor))
|
||||||
.collect::<Vec<bool>>(),
|
.collect::<Vec<bool>>(),
|
||||||
vec![false, true, true, false],
|
vec![false, true, true, false],
|
||||||
"Most recent message should also be cached if not a speculative request."
|
"Most recent message should also be cached if not a speculative request."
|
||||||
|
|
|
@ -789,7 +789,7 @@ impl ContextStore {
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
cx.spawn(async move |this, cx| {
|
cx.spawn(async move |this, cx| {
|
||||||
pub static ZED_STATELESS: LazyLock<bool> =
|
pub static ZED_STATELESS: LazyLock<bool> =
|
||||||
LazyLock::new(|| std::env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty()));
|
LazyLock::new(|| std::env::var("ZED_STATELESS").is_ok_and(|v| !v.is_empty()));
|
||||||
if *ZED_STATELESS {
|
if *ZED_STATELESS {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,9 +62,10 @@ impl SlashCommand for ContextServerSlashCommand {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn requires_argument(&self) -> bool {
|
fn requires_argument(&self) -> bool {
|
||||||
self.prompt.arguments.as_ref().map_or(false, |args| {
|
self.prompt
|
||||||
args.iter().any(|arg| arg.required == Some(true))
|
.arguments
|
||||||
})
|
.as_ref()
|
||||||
|
.is_some_and(|args| args.iter().any(|arg| arg.required == Some(true)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn complete_argument(
|
fn complete_argument(
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl DiagnosticsSlashCommand {
|
||||||
snapshot: worktree.snapshot(),
|
snapshot: worktree.snapshot(),
|
||||||
include_ignored: worktree
|
include_ignored: worktree
|
||||||
.root_entry()
|
.root_entry()
|
||||||
.map_or(false, |entry| entry.is_ignored),
|
.is_some_and(|entry| entry.is_ignored),
|
||||||
include_root_name: true,
|
include_root_name: true,
|
||||||
candidates: project::Candidates::Entries,
|
candidates: project::Candidates::Entries,
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ impl FileSlashCommand {
|
||||||
snapshot: worktree.snapshot(),
|
snapshot: worktree.snapshot(),
|
||||||
include_ignored: worktree
|
include_ignored: worktree
|
||||||
.root_entry()
|
.root_entry()
|
||||||
.map_or(false, |entry| entry.is_ignored),
|
.is_some_and(|entry| entry.is_ignored),
|
||||||
include_root_name: true,
|
include_root_name: true,
|
||||||
candidates: project::Candidates::Entries,
|
candidates: project::Candidates::Entries,
|
||||||
}
|
}
|
||||||
|
@ -536,7 +536,7 @@ mod custom_path_matcher {
|
||||||
let path_str = path.to_string_lossy();
|
let path_str = path.to_string_lossy();
|
||||||
let separator = std::path::MAIN_SEPARATOR_STR;
|
let separator = std::path::MAIN_SEPARATOR_STR;
|
||||||
if path_str.ends_with(separator) {
|
if path_str.ends_with(separator) {
|
||||||
return false;
|
false
|
||||||
} else {
|
} else {
|
||||||
self.glob.is_match(path_str.to_string() + separator)
|
self.glob.is_match(path_str.to_string() + separator)
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ fn register_web_search_tool(registry: &Entity<LanguageModelRegistry>, cx: &mut A
|
||||||
let using_zed_provider = registry
|
let using_zed_provider = registry
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.default_model()
|
.default_model()
|
||||||
.map_or(false, |default| default.is_provided_by_zed());
|
.is_some_and(|default| default.is_provided_by_zed());
|
||||||
if using_zed_provider {
|
if using_zed_provider {
|
||||||
ToolRegistry::global(cx).register_tool(WebSearchTool);
|
ToolRegistry::global(cx).register_tool(WebSearchTool);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1586,7 +1586,7 @@ impl EditAgentTest {
|
||||||
let has_system_prompt = eval
|
let has_system_prompt = eval
|
||||||
.conversation
|
.conversation
|
||||||
.first()
|
.first()
|
||||||
.map_or(false, |msg| msg.role == Role::System);
|
.is_some_and(|msg| msg.role == Role::System);
|
||||||
let messages = if has_system_prompt {
|
let messages = if has_system_prompt {
|
||||||
eval.conversation
|
eval.conversation
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl Tool for ReadFileTool {
|
||||||
buffer
|
buffer
|
||||||
.file()
|
.file()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |file| !file.disk_state().exists())
|
.is_none_or(|file| !file.disk_state().exists())
|
||||||
})? {
|
})? {
|
||||||
anyhow::bail!("{file_path} not found");
|
anyhow::bail!("{file_path} not found");
|
||||||
}
|
}
|
||||||
|
|
|
@ -387,7 +387,7 @@ fn working_dir(
|
||||||
let project = project.read(cx);
|
let project = project.read(cx);
|
||||||
let cd = &input.cd;
|
let cd = &input.cd;
|
||||||
|
|
||||||
if cd == "." || cd == "" {
|
if cd == "." || cd.is_empty() {
|
||||||
// Accept "." or "" as meaning "the one worktree" if we only have one worktree.
|
// Accept "." or "" as meaning "the one worktree" if we only have one worktree.
|
||||||
let mut worktrees = project.worktrees(cx);
|
let mut worktrees = project.worktrees(cx);
|
||||||
|
|
||||||
|
@ -412,10 +412,8 @@ fn working_dir(
|
||||||
{
|
{
|
||||||
return Ok(Some(input_path.into()));
|
return Ok(Some(input_path.into()));
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(worktree) = project.worktree_for_root_name(cd, cx) {
|
||||||
if let Some(worktree) = project.worktree_for_root_name(cd, cx) {
|
return Ok(Some(worktree.read(cx).abs_path().to_path_buf()));
|
||||||
return Ok(Some(worktree.read(cx).abs_path().to_path_buf()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anyhow::bail!("`cd` directory {cd:?} was not in any of the project's worktrees.");
|
anyhow::bail!("`cd` directory {cd:?} was not in any of the project's worktrees.");
|
||||||
|
|
|
@ -54,11 +54,7 @@ pub async fn stream_completion(
|
||||||
)])));
|
)])));
|
||||||
}
|
}
|
||||||
|
|
||||||
if request
|
if request.tools.as_ref().is_some_and(|t| !t.tools.is_empty()) {
|
||||||
.tools
|
|
||||||
.as_ref()
|
|
||||||
.map_or(false, |t| !t.tools.is_empty())
|
|
||||||
{
|
|
||||||
response = response.set_tool_config(request.tools);
|
response = response.set_tool_config(request.tools);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -147,7 +147,7 @@ impl ActiveCall {
|
||||||
let mut incoming_call = this.incoming_call.0.borrow_mut();
|
let mut incoming_call = this.incoming_call.0.borrow_mut();
|
||||||
if incoming_call
|
if incoming_call
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |call| call.room_id == envelope.payload.room_id)
|
.is_some_and(|call| call.room_id == envelope.payload.room_id)
|
||||||
{
|
{
|
||||||
incoming_call.take();
|
incoming_call.take();
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ pub struct RemoteParticipant {
|
||||||
|
|
||||||
impl RemoteParticipant {
|
impl RemoteParticipant {
|
||||||
pub fn has_video_tracks(&self) -> bool {
|
pub fn has_video_tracks(&self) -> bool {
|
||||||
return !self.video_tracks.is_empty();
|
!self.video_tracks.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn can_write(&self) -> bool {
|
pub fn can_write(&self) -> bool {
|
||||||
|
|
|
@ -939,8 +939,7 @@ impl Room {
|
||||||
self.client.user_id()
|
self.client.user_id()
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
if self.live_kit.as_ref().map_or(true, |kit| kit.deafened) && publication.is_audio()
|
if self.live_kit.as_ref().is_none_or(|kit| kit.deafened) && publication.is_audio() {
|
||||||
{
|
|
||||||
publication.set_enabled(false, cx);
|
publication.set_enabled(false, cx);
|
||||||
}
|
}
|
||||||
match track {
|
match track {
|
||||||
|
@ -1174,7 +1173,7 @@ impl Room {
|
||||||
this.update(cx, |this, cx| {
|
this.update(cx, |this, cx| {
|
||||||
this.shared_projects.insert(project.downgrade());
|
this.shared_projects.insert(project.downgrade());
|
||||||
let active_project = this.local_participant.active_project.as_ref();
|
let active_project = this.local_participant.active_project.as_ref();
|
||||||
if active_project.map_or(false, |location| *location == project) {
|
if active_project.is_some_and(|location| *location == project) {
|
||||||
this.set_location(Some(&project), cx)
|
this.set_location(Some(&project), cx)
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Ok(()))
|
Task::ready(Ok(()))
|
||||||
|
@ -1247,9 +1246,9 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_sharing_screen(&self) -> bool {
|
pub fn is_sharing_screen(&self) -> bool {
|
||||||
self.live_kit.as_ref().map_or(false, |live_kit| {
|
self.live_kit
|
||||||
!matches!(live_kit.screen_track, LocalTrack::None)
|
.as_ref()
|
||||||
})
|
.is_some_and(|live_kit| !matches!(live_kit.screen_track, LocalTrack::None))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shared_screen_id(&self) -> Option<u64> {
|
pub fn shared_screen_id(&self) -> Option<u64> {
|
||||||
|
@ -1262,13 +1261,13 @@ impl Room {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_sharing_mic(&self) -> bool {
|
pub fn is_sharing_mic(&self) -> bool {
|
||||||
self.live_kit.as_ref().map_or(false, |live_kit| {
|
self.live_kit
|
||||||
!matches!(live_kit.microphone_track, LocalTrack::None)
|
.as_ref()
|
||||||
})
|
.is_some_and(|live_kit| !matches!(live_kit.microphone_track, LocalTrack::None))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_muted(&self) -> bool {
|
pub fn is_muted(&self) -> bool {
|
||||||
self.live_kit.as_ref().map_or(false, |live_kit| {
|
self.live_kit.as_ref().is_some_and(|live_kit| {
|
||||||
matches!(live_kit.microphone_track, LocalTrack::None)
|
matches!(live_kit.microphone_track, LocalTrack::None)
|
||||||
|| live_kit.muted_by_user
|
|| live_kit.muted_by_user
|
||||||
|| live_kit.deafened
|
|| live_kit.deafened
|
||||||
|
@ -1278,13 +1277,13 @@ impl Room {
|
||||||
pub fn muted_by_user(&self) -> bool {
|
pub fn muted_by_user(&self) -> bool {
|
||||||
self.live_kit
|
self.live_kit
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |live_kit| live_kit.muted_by_user)
|
.is_some_and(|live_kit| live_kit.muted_by_user)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_speaking(&self) -> bool {
|
pub fn is_speaking(&self) -> bool {
|
||||||
self.live_kit
|
self.live_kit
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |live_kit| live_kit.speaking)
|
.is_some_and(|live_kit| live_kit.speaking)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_deafened(&self) -> Option<bool> {
|
pub fn is_deafened(&self) -> Option<bool> {
|
||||||
|
|
|
@ -340,7 +340,7 @@ impl ChannelChat {
|
||||||
return ControlFlow::Break(
|
return ControlFlow::Break(
|
||||||
if cursor
|
if cursor
|
||||||
.item()
|
.item()
|
||||||
.map_or(false, |message| message.id == message_id)
|
.is_some_and(|message| message.id == message_id)
|
||||||
{
|
{
|
||||||
Some(cursor.start().1.0)
|
Some(cursor.start().1.0)
|
||||||
} else {
|
} else {
|
||||||
|
@ -362,7 +362,7 @@ impl ChannelChat {
|
||||||
if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id
|
if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id
|
||||||
&& self
|
&& self
|
||||||
.last_acknowledged_id
|
.last_acknowledged_id
|
||||||
.map_or(true, |acknowledged_id| acknowledged_id < latest_message_id)
|
.is_none_or(|acknowledged_id| acknowledged_id < latest_message_id)
|
||||||
{
|
{
|
||||||
self.rpc
|
self.rpc
|
||||||
.send(proto::AckChannelMessage {
|
.send(proto::AckChannelMessage {
|
||||||
|
@ -612,7 +612,7 @@ impl ChannelChat {
|
||||||
while let Some(message) = old_cursor.item() {
|
while let Some(message) = old_cursor.item() {
|
||||||
let message_ix = old_cursor.start().1.0;
|
let message_ix = old_cursor.start().1.0;
|
||||||
if nonces.contains(&message.nonce) {
|
if nonces.contains(&message.nonce) {
|
||||||
if ranges.last().map_or(false, |r| r.end == message_ix) {
|
if ranges.last().is_some_and(|r| r.end == message_ix) {
|
||||||
ranges.last_mut().unwrap().end += 1;
|
ranges.last_mut().unwrap().end += 1;
|
||||||
} else {
|
} else {
|
||||||
ranges.push(message_ix..message_ix + 1);
|
ranges.push(message_ix..message_ix + 1);
|
||||||
|
|
|
@ -568,16 +568,14 @@ impl ChannelStore {
|
||||||
self.channel_index
|
self.channel_index
|
||||||
.by_id()
|
.by_id()
|
||||||
.get(&channel_id)
|
.get(&channel_id)
|
||||||
.map_or(false, |channel| channel.is_root_channel())
|
.is_some_and(|channel| channel.is_root_channel())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_public_channel(&self, channel_id: ChannelId) -> bool {
|
pub fn is_public_channel(&self, channel_id: ChannelId) -> bool {
|
||||||
self.channel_index
|
self.channel_index
|
||||||
.by_id()
|
.by_id()
|
||||||
.get(&channel_id)
|
.get(&channel_id)
|
||||||
.map_or(false, |channel| {
|
.is_some_and(|channel| channel.visibility == ChannelVisibility::Public)
|
||||||
channel.visibility == ChannelVisibility::Public
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn channel_capability(&self, channel_id: ChannelId) -> Capability {
|
pub fn channel_capability(&self, channel_id: ChannelId) -> Capability {
|
||||||
|
|
|
@ -363,7 +363,7 @@ fn anonymous_fd(path: &str) -> Option<fs::File> {
|
||||||
|
|
||||||
let fd: fd::RawFd = fd_str.parse().ok()?;
|
let fd: fd::RawFd = fd_str.parse().ok()?;
|
||||||
let file = unsafe { fs::File::from_raw_fd(fd) };
|
let file = unsafe { fs::File::from_raw_fd(fd) };
|
||||||
return Some(file);
|
Some(file)
|
||||||
}
|
}
|
||||||
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
#[cfg(any(target_os = "macos", target_os = "freebsd"))]
|
||||||
{
|
{
|
||||||
|
@ -381,13 +381,13 @@ fn anonymous_fd(path: &str) -> Option<fs::File> {
|
||||||
}
|
}
|
||||||
let fd: fd::RawFd = fd_str.parse().ok()?;
|
let fd: fd::RawFd = fd_str.parse().ok()?;
|
||||||
let file = unsafe { fs::File::from_raw_fd(fd) };
|
let file = unsafe { fs::File::from_raw_fd(fd) };
|
||||||
return Some(file);
|
Some(file)
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))]
|
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "freebsd")))]
|
||||||
{
|
{
|
||||||
_ = path;
|
_ = path;
|
||||||
// not implemented for bsd, windows. Could be, but isn't yet
|
// not implemented for bsd, windows. Could be, but isn't yet
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,7 +586,7 @@ mod flatpak {
|
||||||
|
|
||||||
pub fn set_bin_if_no_escape(mut args: super::Args) -> super::Args {
|
pub fn set_bin_if_no_escape(mut args: super::Args) -> super::Args {
|
||||||
if env::var(NO_ESCAPE_ENV_NAME).is_ok()
|
if env::var(NO_ESCAPE_ENV_NAME).is_ok()
|
||||||
&& env::var("FLATPAK_ID").map_or(false, |id| id.starts_with("dev.zed.Zed"))
|
&& env::var("FLATPAK_ID").is_ok_and(|id| id.starts_with("dev.zed.Zed"))
|
||||||
&& args.zed.is_none()
|
&& args.zed.is_none()
|
||||||
{
|
{
|
||||||
args.zed = Some("/app/libexec/zed-editor".into());
|
args.zed = Some("/app/libexec/zed-editor".into());
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub static ZED_APP_PATH: LazyLock<Option<PathBuf>> =
|
||||||
LazyLock::new(|| std::env::var("ZED_APP_PATH").ok().map(PathBuf::from));
|
LazyLock::new(|| std::env::var("ZED_APP_PATH").ok().map(PathBuf::from));
|
||||||
|
|
||||||
pub static ZED_ALWAYS_ACTIVE: LazyLock<bool> =
|
pub static ZED_ALWAYS_ACTIVE: LazyLock<bool> =
|
||||||
LazyLock::new(|| std::env::var("ZED_ALWAYS_ACTIVE").map_or(false, |e| !e.is_empty()));
|
LazyLock::new(|| std::env::var("ZED_ALWAYS_ACTIVE").is_ok_and(|e| !e.is_empty()));
|
||||||
|
|
||||||
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(500);
|
pub const INITIAL_RECONNECTION_DELAY: Duration = Duration::from_millis(500);
|
||||||
pub const MAX_RECONNECTION_DELAY: Duration = Duration::from_secs(30);
|
pub const MAX_RECONNECTION_DELAY: Duration = Duration::from_secs(30);
|
||||||
|
|
|
@ -848,7 +848,7 @@ impl UserStore {
|
||||||
|
|
||||||
pub fn has_accepted_terms_of_service(&self) -> bool {
|
pub fn has_accepted_terms_of_service(&self) -> bool {
|
||||||
self.accepted_tos_at
|
self.accepted_tos_at
|
||||||
.map_or(false, |accepted_tos_at| accepted_tos_at.is_some())
|
.is_some_and(|accepted_tos_at| accepted_tos_at.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn accept_terms_of_service(&self, cx: &Context<Self>) -> Task<Result<()>> {
|
pub fn accept_terms_of_service(&self, cx: &Context<Self>) -> Task<Result<()>> {
|
||||||
|
|
|
@ -205,12 +205,12 @@ impl CloudApiClient {
|
||||||
let mut body = String::new();
|
let mut body = String::new();
|
||||||
response.body_mut().read_to_string(&mut body).await?;
|
response.body_mut().read_to_string(&mut body).await?;
|
||||||
if response.status() == StatusCode::UNAUTHORIZED {
|
if response.status() == StatusCode::UNAUTHORIZED {
|
||||||
return Ok(false);
|
Ok(false)
|
||||||
} else {
|
} else {
|
||||||
return Err(anyhow!(
|
Err(anyhow!(
|
||||||
"Failed to get authenticated user.\nStatus: {:?}\nBody: {body}",
|
"Failed to get authenticated user.\nStatus: {:?}\nBody: {body}",
|
||||||
response.status()
|
response.status()
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,7 +304,7 @@ impl RandomizedTest for ProjectCollaborationTest {
|
||||||
let worktree = worktree.read(cx);
|
let worktree = worktree.read(cx);
|
||||||
worktree.is_visible()
|
worktree.is_visible()
|
||||||
&& worktree.entries(false, 0).any(|e| e.is_file())
|
&& worktree.entries(false, 0).any(|e| e.is_file())
|
||||||
&& worktree.root_entry().map_or(false, |e| e.is_dir())
|
&& worktree.root_entry().is_some_and(|e| e.is_dir())
|
||||||
})
|
})
|
||||||
.choose(rng)
|
.choose(rng)
|
||||||
});
|
});
|
||||||
|
|
|
@ -890,7 +890,7 @@ impl ChatPanel {
|
||||||
this.highlighted_message = Some((highlight_message_id, task));
|
this.highlighted_message = Some((highlight_message_id, task));
|
||||||
}
|
}
|
||||||
|
|
||||||
if this.active_chat.as_ref().map_or(false, |(c, _)| *c == chat) {
|
if this.active_chat.as_ref().is_some_and(|(c, _)| *c == chat) {
|
||||||
this.message_list.scroll_to(ListOffset {
|
this.message_list.scroll_to(ListOffset {
|
||||||
item_ix,
|
item_ix,
|
||||||
offset_in_item: px(0.0),
|
offset_in_item: px(0.0),
|
||||||
|
@ -1186,7 +1186,7 @@ impl Panel for ChatPanel {
|
||||||
let is_in_call = ActiveCall::global(cx)
|
let is_in_call = ActiveCall::global(cx)
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.room()
|
.room()
|
||||||
.map_or(false, |room| room.read(cx).contains_guests());
|
.is_some_and(|room| room.read(cx).contains_guests());
|
||||||
|
|
||||||
self.active || is_in_call
|
self.active || is_in_call
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,9 +664,7 @@ impl CollabPanel {
|
||||||
|
|
||||||
let has_children = channel_store
|
let has_children = channel_store
|
||||||
.channel_at_index(mat.candidate_id + 1)
|
.channel_at_index(mat.candidate_id + 1)
|
||||||
.map_or(false, |next_channel| {
|
.is_some_and(|next_channel| next_channel.parent_path.ends_with(&[channel.id]));
|
||||||
next_channel.parent_path.ends_with(&[channel.id])
|
|
||||||
});
|
|
||||||
|
|
||||||
match &self.channel_editing_state {
|
match &self.channel_editing_state {
|
||||||
Some(ChannelEditingState::Create {
|
Some(ChannelEditingState::Create {
|
||||||
|
@ -1125,7 +1123,7 @@ impl CollabPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_subchannels(&self, ix: usize) -> bool {
|
fn has_subchannels(&self, ix: usize) -> bool {
|
||||||
self.entries.get(ix).map_or(false, |entry| {
|
self.entries.get(ix).is_some_and(|entry| {
|
||||||
if let ListEntry::Channel { has_children, .. } = entry {
|
if let ListEntry::Channel { has_children, .. } = entry {
|
||||||
*has_children
|
*has_children
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -497,7 +497,7 @@ impl NotificationPanel {
|
||||||
panel.is_scrolled_to_bottom()
|
panel.is_scrolled_to_bottom()
|
||||||
&& panel
|
&& panel
|
||||||
.active_chat()
|
.active_chat()
|
||||||
.map_or(false, |chat| chat.read(cx).channel_id.0 == *channel_id)
|
.is_some_and(|chat| chat.read(cx).channel_id.0 == *channel_id)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,7 +19,7 @@ use release_channel::ReleaseChannel;
|
||||||
/// Only works in development. Setting this environment variable in other
|
/// Only works in development. Setting this environment variable in other
|
||||||
/// release channels is a no-op.
|
/// release channels is a no-op.
|
||||||
static ZED_DEVELOPMENT_USE_KEYCHAIN: LazyLock<bool> = LazyLock::new(|| {
|
static ZED_DEVELOPMENT_USE_KEYCHAIN: LazyLock<bool> = LazyLock::new(|| {
|
||||||
std::env::var("ZED_DEVELOPMENT_USE_KEYCHAIN").map_or(false, |value| !value.is_empty())
|
std::env::var("ZED_DEVELOPMENT_USE_KEYCHAIN").is_ok_and(|value| !value.is_empty())
|
||||||
});
|
});
|
||||||
|
|
||||||
/// A provider for credentials.
|
/// A provider for credentials.
|
||||||
|
|
|
@ -385,7 +385,7 @@ impl DebugAdapter for CodeLldbDebugAdapter {
|
||||||
&& let Some(source_languages) = config.get("sourceLanguages").filter(|value| {
|
&& let Some(source_languages) = config.get("sourceLanguages").filter(|value| {
|
||||||
value
|
value
|
||||||
.as_array()
|
.as_array()
|
||||||
.map_or(false, |array| array.iter().all(Value::is_string))
|
.is_some_and(|array| array.iter().all(Value::is_string))
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
let ret = vec![
|
let ret = vec![
|
||||||
|
|
|
@ -37,7 +37,7 @@ const FALLBACK_DB_NAME: &str = "FALLBACK_MEMORY_DB";
|
||||||
const DB_FILE_NAME: &str = "db.sqlite";
|
const DB_FILE_NAME: &str = "db.sqlite";
|
||||||
|
|
||||||
pub static ZED_STATELESS: LazyLock<bool> =
|
pub static ZED_STATELESS: LazyLock<bool> =
|
||||||
LazyLock::new(|| env::var("ZED_STATELESS").map_or(false, |v| !v.is_empty()));
|
LazyLock::new(|| env::var("ZED_STATELESS").is_ok_and(|v| !v.is_empty()));
|
||||||
|
|
||||||
pub static ALL_FILE_DB_FAILED: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
|
pub static ALL_FILE_DB_FAILED: LazyLock<AtomicBool> = LazyLock::new(|| AtomicBool::new(false));
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub trait Dismissable {
|
||||||
KEY_VALUE_STORE
|
KEY_VALUE_STORE
|
||||||
.read_kvp(Self::KEY)
|
.read_kvp(Self::KEY)
|
||||||
.log_err()
|
.log_err()
|
||||||
.map_or(false, |s| s.is_some())
|
.is_some_and(|s| s.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_dismissed(is_dismissed: bool, cx: &mut App) {
|
fn set_dismissed(is_dismissed: bool, cx: &mut App) {
|
||||||
|
|
|
@ -392,7 +392,7 @@ impl LogStore {
|
||||||
session.label(),
|
session.label(),
|
||||||
session
|
session
|
||||||
.adapter_client()
|
.adapter_client()
|
||||||
.map_or(false, |client| client.has_adapter_logs()),
|
.is_some_and(|client| client.has_adapter_logs()),
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -414,7 +414,7 @@ pub(crate) fn new_debugger_pane(
|
||||||
.and_then(|item| item.downcast::<SubView>());
|
.and_then(|item| item.downcast::<SubView>());
|
||||||
let is_hovered = as_subview
|
let is_hovered = as_subview
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |item| item.read(cx).hovered);
|
.is_some_and(|item| item.read(cx).hovered);
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.track_focus(&focus_handle)
|
.track_focus(&focus_handle)
|
||||||
|
@ -427,7 +427,6 @@ pub(crate) fn new_debugger_pane(
|
||||||
.bg(cx.theme().colors().tab_bar_background)
|
.bg(cx.theme().colors().tab_bar_background)
|
||||||
.on_action(|_: &menu::Cancel, window, cx| {
|
.on_action(|_: &menu::Cancel, window, cx| {
|
||||||
if cx.stop_active_drag(window) {
|
if cx.stop_active_drag(window) {
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
cx.propagate();
|
cx.propagate();
|
||||||
}
|
}
|
||||||
|
@ -449,7 +448,7 @@ pub(crate) fn new_debugger_pane(
|
||||||
.children(pane.items().enumerate().map(|(ix, item)| {
|
.children(pane.items().enumerate().map(|(ix, item)| {
|
||||||
let selected = active_pane_item
|
let selected = active_pane_item
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |active| active.item_id() == item.item_id());
|
.is_some_and(|active| active.item_id() == item.item_id());
|
||||||
let deemphasized = !pane.has_focus(window, cx);
|
let deemphasized = !pane.has_focus(window, cx);
|
||||||
let item_ = item.boxed_clone();
|
let item_ = item.boxed_clone();
|
||||||
div()
|
div()
|
||||||
|
|
|
@ -528,7 +528,7 @@ impl BreakpointList {
|
||||||
cx.background_executor()
|
cx.background_executor()
|
||||||
.spawn(async move { KEY_VALUE_STORE.write_kvp(key, value?).await })
|
.spawn(async move { KEY_VALUE_STORE.write_kvp(key, value?).await })
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Result::Ok(()));
|
Task::ready(Result::Ok(()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -287,15 +287,13 @@ impl DiagnosticBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if let Some(diagnostic) = editor
|
||||||
if let Some(diagnostic) = editor
|
.snapshot(window, cx)
|
||||||
.snapshot(window, cx)
|
.buffer_snapshot
|
||||||
.buffer_snapshot
|
.diagnostic_group(buffer_id, group_id)
|
||||||
.diagnostic_group(buffer_id, group_id)
|
.nth(ix)
|
||||||
.nth(ix)
|
{
|
||||||
{
|
Self::jump_to(editor, diagnostic.range, window, cx)
|
||||||
Self::jump_to(editor, diagnostic.range, window, cx)
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -383,12 +383,10 @@ impl ProjectDiagnosticsEditor {
|
||||||
} else {
|
} else {
|
||||||
self.update_all_diagnostics(false, window, cx);
|
self.update_all_diagnostics(false, window, cx);
|
||||||
}
|
}
|
||||||
|
} else if self.update_excerpts_task.is_some() {
|
||||||
|
self.update_excerpts_task = None;
|
||||||
} else {
|
} else {
|
||||||
if self.update_excerpts_task.is_some() {
|
self.update_all_diagnostics(false, window, cx);
|
||||||
self.update_excerpts_task = None;
|
|
||||||
} else {
|
|
||||||
self.update_all_diagnostics(false, window, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
@ -542,7 +540,7 @@ impl ProjectDiagnosticsEditor {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
this.diagnostics.insert(buffer_id, diagnostics.clone());
|
this.diagnostics.insert(buffer_id, diagnostics.clone());
|
||||||
return false;
|
false
|
||||||
})?;
|
})?;
|
||||||
if unchanged {
|
if unchanged {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
|
|
@ -295,7 +295,7 @@ fn dump_all_gpui_actions() -> Vec<ActionDef> {
|
||||||
|
|
||||||
actions.sort_by_key(|a| a.name);
|
actions.sort_by_key(|a| a.name);
|
||||||
|
|
||||||
return actions;
|
actions
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_postprocessing() -> Result<()> {
|
fn handle_postprocessing() -> Result<()> {
|
||||||
|
|
|
@ -185,7 +185,7 @@ impl Render for EditPredictionButton {
|
||||||
let this = cx.entity();
|
let this = cx.entity();
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
|
|
||||||
return div().child(
|
div().child(
|
||||||
PopoverMenu::new("supermaven")
|
PopoverMenu::new("supermaven")
|
||||||
.menu(move |window, cx| match &status {
|
.menu(move |window, cx| match &status {
|
||||||
SupermavenButtonStatus::NeedsActivation(activate_url) => {
|
SupermavenButtonStatus::NeedsActivation(activate_url) => {
|
||||||
|
@ -230,7 +230,7 @@ impl Render for EditPredictionButton {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.with_handle(self.popover_menu_handle.clone()),
|
.with_handle(self.popover_menu_handle.clone()),
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EditPredictionProvider::Zed => {
|
EditPredictionProvider::Zed => {
|
||||||
|
@ -343,7 +343,7 @@ impl Render for EditPredictionButton {
|
||||||
let is_refreshing = self
|
let is_refreshing = self
|
||||||
.edit_prediction_provider
|
.edit_prediction_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |provider| provider.is_refreshing(cx));
|
.is_some_and(|provider| provider.is_refreshing(cx));
|
||||||
|
|
||||||
if is_refreshing {
|
if is_refreshing {
|
||||||
popover_menu = popover_menu.trigger(
|
popover_menu = popover_menu.trigger(
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::{Editor, SwitchSourceHeader, element::register_action};
|
||||||
use project::lsp_store::clangd_ext::CLANGD_SERVER_NAME;
|
use project::lsp_store::clangd_ext::CLANGD_SERVER_NAME;
|
||||||
|
|
||||||
fn is_c_language(language: &Language) -> bool {
|
fn is_c_language(language: &Language) -> bool {
|
||||||
return language.name() == "C++".into() || language.name() == "C".into();
|
language.name() == "C++".into() || language.name() == "C".into()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn switch_source_header(
|
pub fn switch_source_header(
|
||||||
|
|
|
@ -1111,10 +1111,8 @@ impl CompletionsMenu {
|
||||||
let query_start_doesnt_match_split_words = query_start_lower
|
let query_start_doesnt_match_split_words = query_start_lower
|
||||||
.map(|query_char| {
|
.map(|query_char| {
|
||||||
!split_words(&string_match.string).any(|word| {
|
!split_words(&string_match.string).any(|word| {
|
||||||
word.chars()
|
word.chars().next().and_then(|c| c.to_lowercase().next())
|
||||||
.next()
|
== Some(query_char)
|
||||||
.and_then(|c| c.to_lowercase().next())
|
|
||||||
.map_or(false, |word_char| word_char == query_char)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.unwrap_or(false);
|
.unwrap_or(false);
|
||||||
|
|
|
@ -991,7 +991,7 @@ impl DisplaySnapshot {
|
||||||
if let Some(severity) = chunk.diagnostic_severity.filter(|severity| {
|
if let Some(severity) = chunk.diagnostic_severity.filter(|severity| {
|
||||||
self.diagnostics_max_severity
|
self.diagnostics_max_severity
|
||||||
.into_lsp()
|
.into_lsp()
|
||||||
.map_or(false, |max_severity| severity <= &max_severity)
|
.is_some_and(|max_severity| severity <= &max_severity)
|
||||||
}) {
|
}) {
|
||||||
if chunk.is_unnecessary {
|
if chunk.is_unnecessary {
|
||||||
diagnostic_highlight.fade_out = Some(editor_style.unnecessary_code_fade);
|
diagnostic_highlight.fade_out = Some(editor_style.unnecessary_code_fade);
|
||||||
|
|
|
@ -528,10 +528,7 @@ impl BlockMap {
|
||||||
if let Some(transform) = cursor.item()
|
if let Some(transform) = cursor.item()
|
||||||
&& transform.summary.input_rows > 0
|
&& transform.summary.input_rows > 0
|
||||||
&& cursor.end() == old_start
|
&& cursor.end() == old_start
|
||||||
&& transform
|
&& transform.block.as_ref().is_none_or(|b| !b.is_replacement())
|
||||||
.block
|
|
||||||
.as_ref()
|
|
||||||
.map_or(true, |b| !b.is_replacement())
|
|
||||||
{
|
{
|
||||||
// Preserve the transform (push and next)
|
// Preserve the transform (push and next)
|
||||||
new_transforms.push(transform.clone(), &());
|
new_transforms.push(transform.clone(), &());
|
||||||
|
@ -539,7 +536,7 @@ impl BlockMap {
|
||||||
|
|
||||||
// Preserve below blocks at end of edit
|
// Preserve below blocks at end of edit
|
||||||
while let Some(transform) = cursor.item() {
|
while let Some(transform) = cursor.item() {
|
||||||
if transform.block.as_ref().map_or(false, |b| b.place_below()) {
|
if transform.block.as_ref().is_some_and(|b| b.place_below()) {
|
||||||
new_transforms.push(transform.clone(), &());
|
new_transforms.push(transform.clone(), &());
|
||||||
cursor.next();
|
cursor.next();
|
||||||
} else {
|
} else {
|
||||||
|
@ -606,7 +603,7 @@ impl BlockMap {
|
||||||
|
|
||||||
// Discard below blocks at the end of the edit. They'll be reconstructed.
|
// Discard below blocks at the end of the edit. They'll be reconstructed.
|
||||||
while let Some(transform) = cursor.item() {
|
while let Some(transform) = cursor.item() {
|
||||||
if transform.block.as_ref().map_or(false, |b| b.place_below()) {
|
if transform.block.as_ref().is_some_and(|b| b.place_below()) {
|
||||||
cursor.next();
|
cursor.next();
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -1328,7 +1325,7 @@ impl BlockSnapshot {
|
||||||
let Dimensions(output_start, input_start, _) = cursor.start();
|
let Dimensions(output_start, input_start, _) = cursor.start();
|
||||||
let overshoot = if cursor
|
let overshoot = if cursor
|
||||||
.item()
|
.item()
|
||||||
.map_or(false, |transform| transform.block.is_none())
|
.is_some_and(|transform| transform.block.is_none())
|
||||||
{
|
{
|
||||||
start_row.0 - output_start.0
|
start_row.0 - output_start.0
|
||||||
} else {
|
} else {
|
||||||
|
@ -1358,7 +1355,7 @@ impl BlockSnapshot {
|
||||||
&& transform
|
&& transform
|
||||||
.block
|
.block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |block| block.height() > 0))
|
.is_some_and(|block| block.height() > 0))
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1511,7 +1508,7 @@ impl BlockSnapshot {
|
||||||
pub(super) fn is_block_line(&self, row: BlockRow) -> bool {
|
pub(super) fn is_block_line(&self, row: BlockRow) -> bool {
|
||||||
let mut cursor = self.transforms.cursor::<Dimensions<BlockRow, WrapRow>>(&());
|
let mut cursor = self.transforms.cursor::<Dimensions<BlockRow, WrapRow>>(&());
|
||||||
cursor.seek(&row, Bias::Right);
|
cursor.seek(&row, Bias::Right);
|
||||||
cursor.item().map_or(false, |t| t.block.is_some())
|
cursor.item().is_some_and(|t| t.block.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn is_folded_buffer_header(&self, row: BlockRow) -> bool {
|
pub(super) fn is_folded_buffer_header(&self, row: BlockRow) -> bool {
|
||||||
|
@ -1529,11 +1526,11 @@ impl BlockSnapshot {
|
||||||
.make_wrap_point(Point::new(row.0, 0), Bias::Left);
|
.make_wrap_point(Point::new(row.0, 0), Bias::Left);
|
||||||
let mut cursor = self.transforms.cursor::<Dimensions<WrapRow, BlockRow>>(&());
|
let mut cursor = self.transforms.cursor::<Dimensions<WrapRow, BlockRow>>(&());
|
||||||
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right);
|
cursor.seek(&WrapRow(wrap_point.row()), Bias::Right);
|
||||||
cursor.item().map_or(false, |transform| {
|
cursor.item().is_some_and(|transform| {
|
||||||
transform
|
transform
|
||||||
.block
|
.block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |block| block.is_replacement())
|
.is_some_and(|block| block.is_replacement())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1653,7 +1650,7 @@ impl BlockChunks<'_> {
|
||||||
if transform
|
if transform
|
||||||
.block
|
.block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |block| block.height() == 0)
|
.is_some_and(|block| block.height() == 0)
|
||||||
{
|
{
|
||||||
self.transforms.next();
|
self.transforms.next();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1664,7 +1661,7 @@ impl BlockChunks<'_> {
|
||||||
if self
|
if self
|
||||||
.transforms
|
.transforms
|
||||||
.item()
|
.item()
|
||||||
.map_or(false, |transform| transform.block.is_none())
|
.is_some_and(|transform| transform.block.is_none())
|
||||||
{
|
{
|
||||||
let start_input_row = self.transforms.start().1.0;
|
let start_input_row = self.transforms.start().1.0;
|
||||||
let start_output_row = self.transforms.start().0.0;
|
let start_output_row = self.transforms.start().0.0;
|
||||||
|
@ -1774,7 +1771,7 @@ impl Iterator for BlockRows<'_> {
|
||||||
if transform
|
if transform
|
||||||
.block
|
.block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |block| block.height() == 0)
|
.is_some_and(|block| block.height() == 0)
|
||||||
{
|
{
|
||||||
self.transforms.next();
|
self.transforms.next();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1786,7 +1783,7 @@ impl Iterator for BlockRows<'_> {
|
||||||
if transform
|
if transform
|
||||||
.block
|
.block
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |block| block.is_replacement())
|
.is_none_or(|block| block.is_replacement())
|
||||||
{
|
{
|
||||||
self.input_rows.seek(self.transforms.start().1.0);
|
self.input_rows.seek(self.transforms.start().1.0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -491,14 +491,14 @@ impl FoldMap {
|
||||||
|
|
||||||
while folds
|
while folds
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |(_, fold_range)| fold_range.start < edit.new.end)
|
.is_some_and(|(_, fold_range)| fold_range.start < edit.new.end)
|
||||||
{
|
{
|
||||||
let (fold, mut fold_range) = folds.next().unwrap();
|
let (fold, mut fold_range) = folds.next().unwrap();
|
||||||
let sum = new_transforms.summary();
|
let sum = new_transforms.summary();
|
||||||
|
|
||||||
assert!(fold_range.start.0 >= sum.input.len);
|
assert!(fold_range.start.0 >= sum.input.len);
|
||||||
|
|
||||||
while folds.peek().map_or(false, |(next_fold, next_fold_range)| {
|
while folds.peek().is_some_and(|(next_fold, next_fold_range)| {
|
||||||
next_fold_range.start < fold_range.end
|
next_fold_range.start < fold_range.end
|
||||||
|| (next_fold_range.start == fold_range.end
|
|| (next_fold_range.start == fold_range.end
|
||||||
&& fold.placeholder.merge_adjacent
|
&& fold.placeholder.merge_adjacent
|
||||||
|
@ -575,14 +575,14 @@ impl FoldMap {
|
||||||
|
|
||||||
for mut edit in inlay_edits {
|
for mut edit in inlay_edits {
|
||||||
old_transforms.seek(&edit.old.start, Bias::Left);
|
old_transforms.seek(&edit.old.start, Bias::Left);
|
||||||
if old_transforms.item().map_or(false, |t| t.is_fold()) {
|
if old_transforms.item().is_some_and(|t| t.is_fold()) {
|
||||||
edit.old.start = old_transforms.start().0;
|
edit.old.start = old_transforms.start().0;
|
||||||
}
|
}
|
||||||
let old_start =
|
let old_start =
|
||||||
old_transforms.start().1.0 + (edit.old.start - old_transforms.start().0).0;
|
old_transforms.start().1.0 + (edit.old.start - old_transforms.start().0).0;
|
||||||
|
|
||||||
old_transforms.seek_forward(&edit.old.end, Bias::Right);
|
old_transforms.seek_forward(&edit.old.end, Bias::Right);
|
||||||
if old_transforms.item().map_or(false, |t| t.is_fold()) {
|
if old_transforms.item().is_some_and(|t| t.is_fold()) {
|
||||||
old_transforms.next();
|
old_transforms.next();
|
||||||
edit.old.end = old_transforms.start().0;
|
edit.old.end = old_transforms.start().0;
|
||||||
}
|
}
|
||||||
|
@ -590,14 +590,14 @@ impl FoldMap {
|
||||||
old_transforms.start().1.0 + (edit.old.end - old_transforms.start().0).0;
|
old_transforms.start().1.0 + (edit.old.end - old_transforms.start().0).0;
|
||||||
|
|
||||||
new_transforms.seek(&edit.new.start, Bias::Left);
|
new_transforms.seek(&edit.new.start, Bias::Left);
|
||||||
if new_transforms.item().map_or(false, |t| t.is_fold()) {
|
if new_transforms.item().is_some_and(|t| t.is_fold()) {
|
||||||
edit.new.start = new_transforms.start().0;
|
edit.new.start = new_transforms.start().0;
|
||||||
}
|
}
|
||||||
let new_start =
|
let new_start =
|
||||||
new_transforms.start().1.0 + (edit.new.start - new_transforms.start().0).0;
|
new_transforms.start().1.0 + (edit.new.start - new_transforms.start().0).0;
|
||||||
|
|
||||||
new_transforms.seek_forward(&edit.new.end, Bias::Right);
|
new_transforms.seek_forward(&edit.new.end, Bias::Right);
|
||||||
if new_transforms.item().map_or(false, |t| t.is_fold()) {
|
if new_transforms.item().is_some_and(|t| t.is_fold()) {
|
||||||
new_transforms.next();
|
new_transforms.next();
|
||||||
edit.new.end = new_transforms.start().0;
|
edit.new.end = new_transforms.start().0;
|
||||||
}
|
}
|
||||||
|
@ -709,7 +709,7 @@ impl FoldSnapshot {
|
||||||
.transforms
|
.transforms
|
||||||
.cursor::<Dimensions<InlayPoint, FoldPoint>>(&());
|
.cursor::<Dimensions<InlayPoint, FoldPoint>>(&());
|
||||||
cursor.seek(&point, Bias::Right);
|
cursor.seek(&point, Bias::Right);
|
||||||
if cursor.item().map_or(false, |t| t.is_fold()) {
|
if cursor.item().is_some_and(|t| t.is_fold()) {
|
||||||
if bias == Bias::Left || point == cursor.start().0 {
|
if bias == Bias::Left || point == cursor.start().0 {
|
||||||
cursor.start().1
|
cursor.start().1
|
||||||
} else {
|
} else {
|
||||||
|
@ -788,7 +788,7 @@ impl FoldSnapshot {
|
||||||
let inlay_offset = self.inlay_snapshot.to_inlay_offset(buffer_offset);
|
let inlay_offset = self.inlay_snapshot.to_inlay_offset(buffer_offset);
|
||||||
let mut cursor = self.transforms.cursor::<InlayOffset>(&());
|
let mut cursor = self.transforms.cursor::<InlayOffset>(&());
|
||||||
cursor.seek(&inlay_offset, Bias::Right);
|
cursor.seek(&inlay_offset, Bias::Right);
|
||||||
cursor.item().map_or(false, |t| t.placeholder.is_some())
|
cursor.item().is_some_and(|t| t.placeholder.is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_line_folded(&self, buffer_row: MultiBufferRow) -> bool {
|
pub fn is_line_folded(&self, buffer_row: MultiBufferRow) -> bool {
|
||||||
|
@ -839,7 +839,7 @@ impl FoldSnapshot {
|
||||||
|
|
||||||
let inlay_end = if transform_cursor
|
let inlay_end = if transform_cursor
|
||||||
.item()
|
.item()
|
||||||
.map_or(true, |transform| transform.is_fold())
|
.is_none_or(|transform| transform.is_fold())
|
||||||
{
|
{
|
||||||
inlay_start
|
inlay_start
|
||||||
} else if range.end < transform_end.0 {
|
} else if range.end < transform_end.0 {
|
||||||
|
@ -1348,7 +1348,7 @@ impl FoldChunks<'_> {
|
||||||
let inlay_end = if self
|
let inlay_end = if self
|
||||||
.transform_cursor
|
.transform_cursor
|
||||||
.item()
|
.item()
|
||||||
.map_or(true, |transform| transform.is_fold())
|
.is_none_or(|transform| transform.is_fold())
|
||||||
{
|
{
|
||||||
inlay_start
|
inlay_start
|
||||||
} else if range.end < transform_end.0 {
|
} else if range.end < transform_end.0 {
|
||||||
|
@ -1463,7 +1463,7 @@ impl FoldOffset {
|
||||||
.transforms
|
.transforms
|
||||||
.cursor::<Dimensions<FoldOffset, TransformSummary>>(&());
|
.cursor::<Dimensions<FoldOffset, TransformSummary>>(&());
|
||||||
cursor.seek(&self, Bias::Right);
|
cursor.seek(&self, Bias::Right);
|
||||||
let overshoot = if cursor.item().map_or(true, |t| t.is_fold()) {
|
let overshoot = if cursor.item().is_none_or(|t| t.is_fold()) {
|
||||||
Point::new(0, (self.0 - cursor.start().0.0) as u32)
|
Point::new(0, (self.0 - cursor.start().0.0) as u32)
|
||||||
} else {
|
} else {
|
||||||
let inlay_offset = cursor.start().1.input.len + self.0 - cursor.start().0.0;
|
let inlay_offset = cursor.start().1.input.len + self.0 - cursor.start().0.0;
|
||||||
|
|
|
@ -625,7 +625,7 @@ impl InlayMap {
|
||||||
// we can push its remainder.
|
// we can push its remainder.
|
||||||
if buffer_edits_iter
|
if buffer_edits_iter
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(true, |edit| edit.old.start >= cursor.end().0)
|
.is_none_or(|edit| edit.old.start >= cursor.end().0)
|
||||||
{
|
{
|
||||||
let transform_start = new_transforms.summary().input.len;
|
let transform_start = new_transforms.summary().input.len;
|
||||||
let transform_end =
|
let transform_end =
|
||||||
|
|
|
@ -74,10 +74,10 @@ impl WrapRows<'_> {
|
||||||
self.transforms
|
self.transforms
|
||||||
.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
||||||
let mut input_row = self.transforms.start().1.row();
|
let mut input_row = self.transforms.start().1.row();
|
||||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
if self.transforms.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
input_row += start_row - self.transforms.start().0.row();
|
input_row += start_row - self.transforms.start().0.row();
|
||||||
}
|
}
|
||||||
self.soft_wrapped = self.transforms.item().map_or(false, |t| !t.is_isomorphic());
|
self.soft_wrapped = self.transforms.item().is_some_and(|t| !t.is_isomorphic());
|
||||||
self.input_buffer_rows.seek(input_row);
|
self.input_buffer_rows.seek(input_row);
|
||||||
self.input_buffer_row = self.input_buffer_rows.next().unwrap();
|
self.input_buffer_row = self.input_buffer_rows.next().unwrap();
|
||||||
self.output_row = start_row;
|
self.output_row = start_row;
|
||||||
|
@ -603,7 +603,7 @@ impl WrapSnapshot {
|
||||||
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
||||||
transforms.seek(&output_start, Bias::Right);
|
transforms.seek(&output_start, Bias::Right);
|
||||||
let mut input_start = TabPoint(transforms.start().1.0);
|
let mut input_start = TabPoint(transforms.start().1.0);
|
||||||
if transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
if transforms.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
input_start.0 += output_start.0 - transforms.start().0.0;
|
input_start.0 += output_start.0 - transforms.start().0.0;
|
||||||
}
|
}
|
||||||
let input_end = self
|
let input_end = self
|
||||||
|
@ -634,7 +634,7 @@ impl WrapSnapshot {
|
||||||
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Left);
|
cursor.seek(&WrapPoint::new(row + 1, 0), Bias::Left);
|
||||||
if cursor
|
if cursor
|
||||||
.item()
|
.item()
|
||||||
.map_or(false, |transform| transform.is_isomorphic())
|
.is_some_and(|transform| transform.is_isomorphic())
|
||||||
{
|
{
|
||||||
let overshoot = row - cursor.start().0.row();
|
let overshoot = row - cursor.start().0.row();
|
||||||
let tab_row = cursor.start().1.row() + overshoot;
|
let tab_row = cursor.start().1.row() + overshoot;
|
||||||
|
@ -732,10 +732,10 @@ impl WrapSnapshot {
|
||||||
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
||||||
transforms.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
transforms.seek(&WrapPoint::new(start_row, 0), Bias::Left);
|
||||||
let mut input_row = transforms.start().1.row();
|
let mut input_row = transforms.start().1.row();
|
||||||
if transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
if transforms.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
input_row += start_row - transforms.start().0.row();
|
input_row += start_row - transforms.start().0.row();
|
||||||
}
|
}
|
||||||
let soft_wrapped = transforms.item().map_or(false, |t| !t.is_isomorphic());
|
let soft_wrapped = transforms.item().is_some_and(|t| !t.is_isomorphic());
|
||||||
let mut input_buffer_rows = self.tab_snapshot.rows(input_row);
|
let mut input_buffer_rows = self.tab_snapshot.rows(input_row);
|
||||||
let input_buffer_row = input_buffer_rows.next().unwrap();
|
let input_buffer_row = input_buffer_rows.next().unwrap();
|
||||||
WrapRows {
|
WrapRows {
|
||||||
|
@ -754,7 +754,7 @@ impl WrapSnapshot {
|
||||||
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
.cursor::<Dimensions<WrapPoint, TabPoint>>(&());
|
||||||
cursor.seek(&point, Bias::Right);
|
cursor.seek(&point, Bias::Right);
|
||||||
let mut tab_point = cursor.start().1.0;
|
let mut tab_point = cursor.start().1.0;
|
||||||
if cursor.item().map_or(false, |t| t.is_isomorphic()) {
|
if cursor.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
tab_point += point.0 - cursor.start().0.0;
|
tab_point += point.0 - cursor.start().0.0;
|
||||||
}
|
}
|
||||||
TabPoint(tab_point)
|
TabPoint(tab_point)
|
||||||
|
@ -780,7 +780,7 @@ impl WrapSnapshot {
|
||||||
if bias == Bias::Left {
|
if bias == Bias::Left {
|
||||||
let mut cursor = self.transforms.cursor::<WrapPoint>(&());
|
let mut cursor = self.transforms.cursor::<WrapPoint>(&());
|
||||||
cursor.seek(&point, Bias::Right);
|
cursor.seek(&point, Bias::Right);
|
||||||
if cursor.item().map_or(false, |t| !t.is_isomorphic()) {
|
if cursor.item().is_some_and(|t| !t.is_isomorphic()) {
|
||||||
point = *cursor.start();
|
point = *cursor.start();
|
||||||
*point.column_mut() -= 1;
|
*point.column_mut() -= 1;
|
||||||
}
|
}
|
||||||
|
@ -901,7 +901,7 @@ impl WrapChunks<'_> {
|
||||||
let output_end = WrapPoint::new(rows.end, 0);
|
let output_end = WrapPoint::new(rows.end, 0);
|
||||||
self.transforms.seek(&output_start, Bias::Right);
|
self.transforms.seek(&output_start, Bias::Right);
|
||||||
let mut input_start = TabPoint(self.transforms.start().1.0);
|
let mut input_start = TabPoint(self.transforms.start().1.0);
|
||||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
if self.transforms.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
input_start.0 += output_start.0 - self.transforms.start().0.0;
|
input_start.0 += output_start.0 - self.transforms.start().0.0;
|
||||||
}
|
}
|
||||||
let input_end = self
|
let input_end = self
|
||||||
|
@ -993,7 +993,7 @@ impl Iterator for WrapRows<'_> {
|
||||||
self.output_row += 1;
|
self.output_row += 1;
|
||||||
self.transforms
|
self.transforms
|
||||||
.seek_forward(&WrapPoint::new(self.output_row, 0), Bias::Left);
|
.seek_forward(&WrapPoint::new(self.output_row, 0), Bias::Left);
|
||||||
if self.transforms.item().map_or(false, |t| t.is_isomorphic()) {
|
if self.transforms.item().is_some_and(|t| t.is_isomorphic()) {
|
||||||
self.input_buffer_row = self.input_buffer_rows.next().unwrap();
|
self.input_buffer_row = self.input_buffer_rows.next().unwrap();
|
||||||
self.soft_wrapped = false;
|
self.soft_wrapped = false;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ impl SelectionHistory {
|
||||||
if self
|
if self
|
||||||
.undo_stack
|
.undo_stack
|
||||||
.back()
|
.back()
|
||||||
.map_or(true, |e| e.selections != entry.selections)
|
.is_none_or(|e| e.selections != entry.selections)
|
||||||
{
|
{
|
||||||
self.undo_stack.push_back(entry);
|
self.undo_stack.push_back(entry);
|
||||||
if self.undo_stack.len() > MAX_SELECTION_HISTORY_LEN {
|
if self.undo_stack.len() > MAX_SELECTION_HISTORY_LEN {
|
||||||
|
@ -1442,7 +1442,7 @@ impl SelectionHistory {
|
||||||
if self
|
if self
|
||||||
.redo_stack
|
.redo_stack
|
||||||
.back()
|
.back()
|
||||||
.map_or(true, |e| e.selections != entry.selections)
|
.is_none_or(|e| e.selections != entry.selections)
|
||||||
{
|
{
|
||||||
self.redo_stack.push_back(entry);
|
self.redo_stack.push_back(entry);
|
||||||
if self.redo_stack.len() > MAX_SELECTION_HISTORY_LEN {
|
if self.redo_stack.len() > MAX_SELECTION_HISTORY_LEN {
|
||||||
|
@ -2512,9 +2512,7 @@ impl Editor {
|
||||||
.context_menu
|
.context_menu
|
||||||
.borrow()
|
.borrow()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |context| {
|
.is_some_and(|context| matches!(context, CodeContextMenu::Completions(_)));
|
||||||
matches!(context, CodeContextMenu::Completions(_))
|
|
||||||
});
|
|
||||||
|
|
||||||
showing_completions
|
showing_completions
|
||||||
|| self.edit_prediction_requires_modifier()
|
|| self.edit_prediction_requires_modifier()
|
||||||
|
@ -2545,7 +2543,7 @@ impl Editor {
|
||||||
|| binding
|
|| binding
|
||||||
.keystrokes()
|
.keystrokes()
|
||||||
.first()
|
.first()
|
||||||
.map_or(false, |keystroke| keystroke.modifiers.modified())
|
.is_some_and(|keystroke| keystroke.modifiers.modified())
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2941,7 +2939,7 @@ impl Editor {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
scope.override_name().map_or(false, |scope_name| {
|
scope.override_name().is_some_and(|scope_name| {
|
||||||
settings
|
settings
|
||||||
.edit_predictions_disabled_in
|
.edit_predictions_disabled_in
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -4033,18 +4031,18 @@ impl Editor {
|
||||||
let following_text_allows_autoclose = snapshot
|
let following_text_allows_autoclose = snapshot
|
||||||
.chars_at(selection.start)
|
.chars_at(selection.start)
|
||||||
.next()
|
.next()
|
||||||
.map_or(true, |c| scope.should_autoclose_before(c));
|
.is_none_or(|c| scope.should_autoclose_before(c));
|
||||||
|
|
||||||
let preceding_text_allows_autoclose = selection.start.column == 0
|
let preceding_text_allows_autoclose = selection.start.column == 0
|
||||||
|| snapshot.reversed_chars_at(selection.start).next().map_or(
|
|| snapshot
|
||||||
true,
|
.reversed_chars_at(selection.start)
|
||||||
|c| {
|
.next()
|
||||||
|
.is_none_or(|c| {
|
||||||
bracket_pair.start != bracket_pair.end
|
bracket_pair.start != bracket_pair.end
|
||||||
|| !snapshot
|
|| !snapshot
|
||||||
.char_classifier_at(selection.start)
|
.char_classifier_at(selection.start)
|
||||||
.is_word(c)
|
.is_word(c)
|
||||||
},
|
});
|
||||||
);
|
|
||||||
|
|
||||||
let is_closing_quote = if bracket_pair.end == bracket_pair.start
|
let is_closing_quote = if bracket_pair.end == bracket_pair.start
|
||||||
&& bracket_pair.start.len() == 1
|
&& bracket_pair.start.len() == 1
|
||||||
|
@ -4185,7 +4183,7 @@ impl Editor {
|
||||||
if !self.linked_edit_ranges.is_empty() {
|
if !self.linked_edit_ranges.is_empty() {
|
||||||
let start_anchor = snapshot.anchor_before(selection.start);
|
let start_anchor = snapshot.anchor_before(selection.start);
|
||||||
|
|
||||||
let is_word_char = text.chars().next().map_or(true, |char| {
|
let is_word_char = text.chars().next().is_none_or(|char| {
|
||||||
let classifier = snapshot
|
let classifier = snapshot
|
||||||
.char_classifier_at(start_anchor.to_offset(&snapshot))
|
.char_classifier_at(start_anchor.to_offset(&snapshot))
|
||||||
.ignore_punctuation(true);
|
.ignore_punctuation(true);
|
||||||
|
@ -5427,11 +5425,11 @@ impl Editor {
|
||||||
|
|
||||||
let sort_completions = provider
|
let sort_completions = provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |provider| provider.sort_completions());
|
.is_some_and(|provider| provider.sort_completions());
|
||||||
|
|
||||||
let filter_completions = provider
|
let filter_completions = provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |provider| provider.filter_completions());
|
.is_none_or(|provider| provider.filter_completions());
|
||||||
|
|
||||||
let trigger_kind = match trigger {
|
let trigger_kind = match trigger {
|
||||||
Some(trigger) if buffer.read(cx).completion_triggers().contains(trigger) => {
|
Some(trigger) if buffer.read(cx).completion_triggers().contains(trigger) => {
|
||||||
|
@ -5537,7 +5535,7 @@ impl Editor {
|
||||||
|
|
||||||
let skip_digits = query
|
let skip_digits = query
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |query| !query.chars().any(|c| c.is_digit(10)));
|
.is_none_or(|query| !query.chars().any(|c| c.is_digit(10)));
|
||||||
|
|
||||||
let (mut words, provider_responses) = match &provider {
|
let (mut words, provider_responses) = match &provider {
|
||||||
Some(provider) => {
|
Some(provider) => {
|
||||||
|
@ -5971,7 +5969,7 @@ impl Editor {
|
||||||
let show_new_completions_on_confirm = completion
|
let show_new_completions_on_confirm = completion
|
||||||
.confirm
|
.confirm
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |confirm| confirm(intent, window, cx));
|
.is_some_and(|confirm| confirm(intent, window, cx));
|
||||||
if show_new_completions_on_confirm {
|
if show_new_completions_on_confirm {
|
||||||
self.show_completions(&ShowCompletions { trigger: None }, window, cx);
|
self.show_completions(&ShowCompletions { trigger: None }, window, cx);
|
||||||
}
|
}
|
||||||
|
@ -6103,10 +6101,10 @@ impl Editor {
|
||||||
let spawn_straight_away = quick_launch
|
let spawn_straight_away = quick_launch
|
||||||
&& resolved_tasks
|
&& resolved_tasks
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |tasks| tasks.templates.len() == 1)
|
.is_some_and(|tasks| tasks.templates.len() == 1)
|
||||||
&& code_actions
|
&& code_actions
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |actions| actions.is_empty())
|
.is_none_or(|actions| actions.is_empty())
|
||||||
&& debug_scenarios.is_empty();
|
&& debug_scenarios.is_empty();
|
||||||
|
|
||||||
editor.update_in(cx, |editor, window, cx| {
|
editor.update_in(cx, |editor, window, cx| {
|
||||||
|
@ -6720,9 +6718,9 @@ impl Editor {
|
||||||
|
|
||||||
let buffer_id = cursor_position.buffer_id;
|
let buffer_id = cursor_position.buffer_id;
|
||||||
let buffer = this.buffer.read(cx);
|
let buffer = this.buffer.read(cx);
|
||||||
if !buffer
|
if buffer
|
||||||
.text_anchor_for_position(cursor_position, cx)
|
.text_anchor_for_position(cursor_position, cx)
|
||||||
.map_or(false, |(buffer, _)| buffer == cursor_buffer)
|
.is_none_or(|(buffer, _)| buffer != cursor_buffer)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6972,9 +6970,7 @@ impl Editor {
|
||||||
|| self
|
|| self
|
||||||
.quick_selection_highlight_task
|
.quick_selection_highlight_task
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |(prev_anchor_range, _)| {
|
.is_none_or(|(prev_anchor_range, _)| prev_anchor_range != &query_range)
|
||||||
prev_anchor_range != &query_range
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
let multi_buffer_visible_start = self
|
let multi_buffer_visible_start = self
|
||||||
.scroll_manager
|
.scroll_manager
|
||||||
|
@ -7003,9 +6999,7 @@ impl Editor {
|
||||||
|| self
|
|| self
|
||||||
.debounced_selection_highlight_task
|
.debounced_selection_highlight_task
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(true, |(prev_anchor_range, _)| {
|
.is_none_or(|(prev_anchor_range, _)| prev_anchor_range != &query_range)
|
||||||
prev_anchor_range != &query_range
|
|
||||||
})
|
|
||||||
{
|
{
|
||||||
let multi_buffer_start = multi_buffer_snapshot
|
let multi_buffer_start = multi_buffer_snapshot
|
||||||
.anchor_before(0)
|
.anchor_before(0)
|
||||||
|
@ -7140,9 +7134,7 @@ impl Editor {
|
||||||
&& self
|
&& self
|
||||||
.edit_prediction_provider
|
.edit_prediction_provider
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |provider| {
|
.is_some_and(|provider| provider.provider.show_completions_in_menu());
|
||||||
provider.provider.show_completions_in_menu()
|
|
||||||
});
|
|
||||||
|
|
||||||
let preview_requires_modifier =
|
let preview_requires_modifier =
|
||||||
all_language_settings(file, cx).edit_predictions_mode() == EditPredictionsMode::Subtle;
|
all_language_settings(file, cx).edit_predictions_mode() == EditPredictionsMode::Subtle;
|
||||||
|
@ -7726,7 +7718,7 @@ impl Editor {
|
||||||
|| self
|
|| self
|
||||||
.active_edit_prediction
|
.active_edit_prediction
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |completion| {
|
.is_some_and(|completion| {
|
||||||
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
|
let invalidation_range = completion.invalidation_range.to_offset(&multibuffer);
|
||||||
let invalidation_range = invalidation_range.start..=invalidation_range.end;
|
let invalidation_range = invalidation_range.start..=invalidation_range.end;
|
||||||
!invalidation_range.contains(&offset_selection.head())
|
!invalidation_range.contains(&offset_selection.head())
|
||||||
|
@ -8427,7 +8419,7 @@ impl Editor {
|
||||||
.context_menu
|
.context_menu
|
||||||
.borrow()
|
.borrow()
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |menu| menu.visible())
|
.is_some_and(|menu| menu.visible())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn context_menu_origin(&self) -> Option<ContextMenuOrigin> {
|
pub fn context_menu_origin(&self) -> Option<ContextMenuOrigin> {
|
||||||
|
@ -8973,9 +8965,8 @@ impl Editor {
|
||||||
let end_row = start_row + line_count as u32;
|
let end_row = start_row + line_count as u32;
|
||||||
visible_row_range.contains(&start_row)
|
visible_row_range.contains(&start_row)
|
||||||
&& visible_row_range.contains(&end_row)
|
&& visible_row_range.contains(&end_row)
|
||||||
&& cursor_row.map_or(true, |cursor_row| {
|
&& cursor_row
|
||||||
!((start_row..end_row).contains(&cursor_row))
|
.is_none_or(|cursor_row| !((start_row..end_row).contains(&cursor_row)))
|
||||||
})
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
content_origin
|
content_origin
|
||||||
|
@ -9585,7 +9576,7 @@ impl Editor {
|
||||||
.tabstops
|
.tabstops
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tabstop| {
|
.map(|tabstop| {
|
||||||
let is_end_tabstop = tabstop.ranges.first().map_or(false, |tabstop| {
|
let is_end_tabstop = tabstop.ranges.first().is_some_and(|tabstop| {
|
||||||
tabstop.is_empty() && tabstop.start == snippet.text.len() as isize
|
tabstop.is_empty() && tabstop.start == snippet.text.len() as isize
|
||||||
});
|
});
|
||||||
let mut tabstop_ranges = tabstop
|
let mut tabstop_ranges = tabstop
|
||||||
|
@ -11716,7 +11707,7 @@ impl Editor {
|
||||||
let transpose_start = display_map
|
let transpose_start = display_map
|
||||||
.buffer_snapshot
|
.buffer_snapshot
|
||||||
.clip_offset(transpose_offset.saturating_sub(1), Bias::Left);
|
.clip_offset(transpose_offset.saturating_sub(1), Bias::Left);
|
||||||
if edits.last().map_or(true, |e| e.0.end <= transpose_start) {
|
if edits.last().is_none_or(|e| e.0.end <= transpose_start) {
|
||||||
let transpose_end = display_map
|
let transpose_end = display_map
|
||||||
.buffer_snapshot
|
.buffer_snapshot
|
||||||
.clip_offset(transpose_offset + 1, Bias::Right);
|
.clip_offset(transpose_offset + 1, Bias::Right);
|
||||||
|
@ -16229,23 +16220,21 @@ impl Editor {
|
||||||
|
|
||||||
if split {
|
if split {
|
||||||
workspace.split_item(SplitDirection::Right, item.clone(), window, cx);
|
workspace.split_item(SplitDirection::Right, item.clone(), window, cx);
|
||||||
} else {
|
} else if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
||||||
if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
|
let (preview_item_id, preview_item_idx) =
|
||||||
let (preview_item_id, preview_item_idx) =
|
workspace.active_pane().read_with(cx, |pane, _| {
|
||||||
workspace.active_pane().read_with(cx, |pane, _| {
|
(pane.preview_item_id(), pane.preview_item_idx())
|
||||||
(pane.preview_item_id(), pane.preview_item_idx())
|
});
|
||||||
});
|
|
||||||
|
|
||||||
workspace.add_item_to_active_pane(item.clone(), preview_item_idx, true, window, cx);
|
workspace.add_item_to_active_pane(item.clone(), preview_item_idx, true, window, cx);
|
||||||
|
|
||||||
if let Some(preview_item_id) = preview_item_id {
|
if let Some(preview_item_id) = preview_item_id {
|
||||||
workspace.active_pane().update(cx, |pane, cx| {
|
workspace.active_pane().update(cx, |pane, cx| {
|
||||||
pane.remove_item(preview_item_id, false, false, window, cx);
|
pane.remove_item(preview_item_id, false, false, window, cx);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
} else {
|
|
||||||
workspace.add_item_to_active_pane(item.clone(), None, true, window, cx);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
workspace.add_item_to_active_pane(item.clone(), None, true, window, cx);
|
||||||
}
|
}
|
||||||
workspace.active_pane().update(cx, |pane, cx| {
|
workspace.active_pane().update(cx, |pane, cx| {
|
||||||
pane.set_preview_item_id(Some(item_id), cx);
|
pane.set_preview_item_id(Some(item_id), cx);
|
||||||
|
@ -19010,7 +18999,7 @@ impl Editor {
|
||||||
|
|
||||||
fn has_blame_entries(&self, cx: &App) -> bool {
|
fn has_blame_entries(&self, cx: &App) -> bool {
|
||||||
self.blame()
|
self.blame()
|
||||||
.map_or(false, |blame| blame.read(cx).has_generated_entries())
|
.is_some_and(|blame| blame.read(cx).has_generated_entries())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn newest_selection_head_on_empty_line(&self, cx: &App) -> bool {
|
fn newest_selection_head_on_empty_line(&self, cx: &App) -> bool {
|
||||||
|
@ -19660,7 +19649,7 @@ impl Editor {
|
||||||
pub fn has_background_highlights<T: 'static>(&self) -> bool {
|
pub fn has_background_highlights<T: 'static>(&self) -> bool {
|
||||||
self.background_highlights
|
self.background_highlights
|
||||||
.get(&HighlightKey::Type(TypeId::of::<T>()))
|
.get(&HighlightKey::Type(TypeId::of::<T>()))
|
||||||
.map_or(false, |(_, highlights)| !highlights.is_empty())
|
.is_some_and(|(_, highlights)| !highlights.is_empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn background_highlights_in_range(
|
pub fn background_highlights_in_range(
|
||||||
|
@ -20582,7 +20571,7 @@ impl Editor {
|
||||||
// For now, don't allow opening excerpts in buffers that aren't backed by
|
// For now, don't allow opening excerpts in buffers that aren't backed by
|
||||||
// regular project files.
|
// regular project files.
|
||||||
fn can_open_excerpts_in_file(file: Option<&Arc<dyn language::File>>) -> bool {
|
fn can_open_excerpts_in_file(file: Option<&Arc<dyn language::File>>) -> bool {
|
||||||
file.map_or(true, |file| project::File::from_dyn(Some(file)).is_some())
|
file.is_none_or(|file| project::File::from_dyn(Some(file)).is_some())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn marked_text_ranges(&self, cx: &App) -> Option<Vec<Range<OffsetUtf16>>> {
|
fn marked_text_ranges(&self, cx: &App) -> Option<Vec<Range<OffsetUtf16>>> {
|
||||||
|
@ -21125,7 +21114,7 @@ impl Editor {
|
||||||
|
|
||||||
pub fn has_visible_completions_menu(&self) -> bool {
|
pub fn has_visible_completions_menu(&self) -> bool {
|
||||||
!self.edit_prediction_preview_is_active()
|
!self.edit_prediction_preview_is_active()
|
||||||
&& self.context_menu.borrow().as_ref().map_or(false, |menu| {
|
&& self.context_menu.borrow().as_ref().is_some_and(|menu| {
|
||||||
menu.visible() && matches!(menu, CodeContextMenu::Completions(_))
|
menu.visible() && matches!(menu, CodeContextMenu::Completions(_))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -21548,9 +21537,9 @@ fn is_grapheme_whitespace(text: &str) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_stay_with_preceding_ideograph(text: &str) -> bool {
|
fn should_stay_with_preceding_ideograph(text: &str) -> bool {
|
||||||
text.chars().next().map_or(false, |ch| {
|
text.chars()
|
||||||
matches!(ch, '。' | '、' | ',' | '?' | '!' | ':' | ';' | '…')
|
.next()
|
||||||
})
|
.is_some_and(|ch| matches!(ch, '。' | '、' | ',' | '?' | '!' | ':' | ';' | '…'))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
||||||
|
@ -21589,11 +21578,11 @@ impl<'a> Iterator for WordBreakingTokenizer<'a> {
|
||||||
} else {
|
} else {
|
||||||
let mut words = self.input[offset..].split_word_bound_indices().peekable();
|
let mut words = self.input[offset..].split_word_bound_indices().peekable();
|
||||||
let mut next_word_bound = words.peek().copied();
|
let mut next_word_bound = words.peek().copied();
|
||||||
if next_word_bound.map_or(false, |(i, _)| i == 0) {
|
if next_word_bound.is_some_and(|(i, _)| i == 0) {
|
||||||
next_word_bound = words.next();
|
next_word_bound = words.next();
|
||||||
}
|
}
|
||||||
while let Some(grapheme) = iter.peek().copied() {
|
while let Some(grapheme) = iter.peek().copied() {
|
||||||
if next_word_bound.map_or(false, |(i, _)| i == offset) {
|
if next_word_bound.is_some_and(|(i, _)| i == offset) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
if is_grapheme_whitespace(grapheme) != is_whitespace
|
if is_grapheme_whitespace(grapheme) != is_whitespace
|
||||||
|
|
|
@ -810,10 +810,8 @@ impl Settings for EditorSettings {
|
||||||
if gutter.line_numbers.is_some() {
|
if gutter.line_numbers.is_some() {
|
||||||
old_gutter.line_numbers = gutter.line_numbers
|
old_gutter.line_numbers = gutter.line_numbers
|
||||||
}
|
}
|
||||||
} else {
|
} else if gutter != GutterContent::default() {
|
||||||
if gutter != GutterContent::default() {
|
current.gutter = Some(gutter)
|
||||||
current.gutter = Some(gutter)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if let Some(b) = vscode.read_bool("editor.scrollBeyondLastLine") {
|
if let Some(b) = vscode.read_bool("editor.scrollBeyondLastLine") {
|
||||||
current.scroll_beyond_last_line = Some(if b {
|
current.scroll_beyond_last_line = Some(if b {
|
||||||
|
|
|
@ -919,6 +919,7 @@ impl EditorElement {
|
||||||
{
|
{
|
||||||
#[allow(
|
#[allow(
|
||||||
clippy::collapsible_if,
|
clippy::collapsible_if,
|
||||||
|
clippy::needless_return,
|
||||||
reason = "The cfg-block below makes this a false positive"
|
reason = "The cfg-block below makes this a false positive"
|
||||||
)]
|
)]
|
||||||
if !text_hitbox.is_hovered(window) || editor.read_only(cx) {
|
if !text_hitbox.is_hovered(window) || editor.read_only(cx) {
|
||||||
|
@ -1126,26 +1127,24 @@ impl EditorElement {
|
||||||
|
|
||||||
let hovered_diff_hunk_row = if let Some(control_row) = hovered_diff_control {
|
let hovered_diff_hunk_row = if let Some(control_row) = hovered_diff_control {
|
||||||
Some(control_row)
|
Some(control_row)
|
||||||
} else {
|
} else if text_hovered {
|
||||||
if text_hovered {
|
let current_row = valid_point.row();
|
||||||
let current_row = valid_point.row();
|
position_map.display_hunks.iter().find_map(|(hunk, _)| {
|
||||||
position_map.display_hunks.iter().find_map(|(hunk, _)| {
|
if let DisplayDiffHunk::Unfolded {
|
||||||
if let DisplayDiffHunk::Unfolded {
|
display_row_range, ..
|
||||||
display_row_range, ..
|
} = hunk
|
||||||
} = hunk
|
{
|
||||||
{
|
if display_row_range.contains(¤t_row) {
|
||||||
if display_row_range.contains(¤t_row) {
|
Some(display_row_range.start)
|
||||||
Some(display_row_range.start)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
} else {
|
||||||
} else {
|
None
|
||||||
None
|
}
|
||||||
}
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if hovered_diff_hunk_row != editor.hovered_diff_hunk_row {
|
if hovered_diff_hunk_row != editor.hovered_diff_hunk_row {
|
||||||
|
@ -1159,11 +1158,11 @@ impl EditorElement {
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|state| state.popover_bounds)
|
.and_then(|state| state.popover_bounds)
|
||||||
.map_or(false, |bounds| bounds.contains(&event.position));
|
.is_some_and(|bounds| bounds.contains(&event.position));
|
||||||
let keyboard_grace = editor
|
let keyboard_grace = editor
|
||||||
.inline_blame_popover
|
.inline_blame_popover
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |state| state.keyboard_grace);
|
.is_some_and(|state| state.keyboard_grace);
|
||||||
|
|
||||||
if mouse_over_inline_blame || mouse_over_popover {
|
if mouse_over_inline_blame || mouse_over_popover {
|
||||||
editor.show_blame_popover(blame_entry, event.position, false, cx);
|
editor.show_blame_popover(blame_entry, event.position, false, cx);
|
||||||
|
@ -1190,10 +1189,10 @@ impl EditorElement {
|
||||||
let is_visible = editor
|
let is_visible = editor
|
||||||
.gutter_breakpoint_indicator
|
.gutter_breakpoint_indicator
|
||||||
.0
|
.0
|
||||||
.map_or(false, |indicator| indicator.is_active);
|
.is_some_and(|indicator| indicator.is_active);
|
||||||
|
|
||||||
let has_existing_breakpoint =
|
let has_existing_breakpoint =
|
||||||
editor.breakpoint_store.as_ref().map_or(false, |store| {
|
editor.breakpoint_store.as_ref().is_some_and(|store| {
|
||||||
let Some(project) = &editor.project else {
|
let Some(project) = &editor.project else {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
@ -2220,12 +2219,11 @@ impl EditorElement {
|
||||||
cmp::max(padded_line, min_start)
|
cmp::max(padded_line, min_start)
|
||||||
};
|
};
|
||||||
|
|
||||||
let behind_edit_prediction_popover = edit_prediction_popover_origin.as_ref().map_or(
|
let behind_edit_prediction_popover = edit_prediction_popover_origin
|
||||||
false,
|
.as_ref()
|
||||||
|edit_prediction_popover_origin| {
|
.is_some_and(|edit_prediction_popover_origin| {
|
||||||
(pos_y..pos_y + line_height).contains(&edit_prediction_popover_origin.y)
|
(pos_y..pos_y + line_height).contains(&edit_prediction_popover_origin.y)
|
||||||
},
|
});
|
||||||
);
|
|
||||||
let opacity = if behind_edit_prediction_popover {
|
let opacity = if behind_edit_prediction_popover {
|
||||||
0.5
|
0.5
|
||||||
} else {
|
} else {
|
||||||
|
@ -2291,9 +2289,7 @@ impl EditorElement {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.map_or(false, |source| {
|
.is_some_and(|source| matches!(source, CodeActionSource::Indicator(..)));
|
||||||
matches!(source, CodeActionSource::Indicator(..))
|
|
||||||
});
|
|
||||||
Some(editor.render_inline_code_actions(icon_size, display_point.row(), active, cx))
|
Some(editor.render_inline_code_actions(icon_size, display_point.row(), active, cx))
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
@ -2909,7 +2905,7 @@ impl EditorElement {
|
||||||
if multibuffer_row
|
if multibuffer_row
|
||||||
.0
|
.0
|
||||||
.checked_sub(1)
|
.checked_sub(1)
|
||||||
.map_or(false, |previous_row| {
|
.is_some_and(|previous_row| {
|
||||||
snapshot.is_line_folded(MultiBufferRow(previous_row))
|
snapshot.is_line_folded(MultiBufferRow(previous_row))
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
|
@ -3900,7 +3896,7 @@ impl EditorElement {
|
||||||
for (row, block) in fixed_blocks {
|
for (row, block) in fixed_blocks {
|
||||||
let block_id = block.id();
|
let block_id = block.id();
|
||||||
|
|
||||||
if focused_block.as_ref().map_or(false, |b| b.id == block_id) {
|
if focused_block.as_ref().is_some_and(|b| b.id == block_id) {
|
||||||
focused_block = None;
|
focused_block = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3957,7 +3953,7 @@ impl EditorElement {
|
||||||
};
|
};
|
||||||
let block_id = block.id();
|
let block_id = block.id();
|
||||||
|
|
||||||
if focused_block.as_ref().map_or(false, |b| b.id == block_id) {
|
if focused_block.as_ref().is_some_and(|b| b.id == block_id) {
|
||||||
focused_block = None;
|
focused_block = None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4736,7 +4732,7 @@ impl EditorElement {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let source_included = source_display_point.map_or(true, |source_display_point| {
|
let source_included = source_display_point.is_none_or(|source_display_point| {
|
||||||
visible_range
|
visible_range
|
||||||
.to_inclusive()
|
.to_inclusive()
|
||||||
.contains(&source_display_point.row())
|
.contains(&source_display_point.row())
|
||||||
|
@ -4916,7 +4912,7 @@ impl EditorElement {
|
||||||
let intersects_menu = |bounds: Bounds<Pixels>| -> bool {
|
let intersects_menu = |bounds: Bounds<Pixels>| -> bool {
|
||||||
context_menu_layout
|
context_menu_layout
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |menu| bounds.intersects(&menu.bounds))
|
.is_some_and(|menu| bounds.intersects(&menu.bounds))
|
||||||
};
|
};
|
||||||
|
|
||||||
let can_place_above = {
|
let can_place_above = {
|
||||||
|
@ -5101,7 +5097,7 @@ impl EditorElement {
|
||||||
|
|
||||||
if active_positions
|
if active_positions
|
||||||
.iter()
|
.iter()
|
||||||
.any(|p| p.map_or(false, |p| display_row_range.contains(&p.row())))
|
.any(|p| p.is_some_and(|p| display_row_range.contains(&p.row())))
|
||||||
{
|
{
|
||||||
let y = display_row_range.start.as_f32() * line_height
|
let y = display_row_range.start.as_f32() * line_height
|
||||||
+ text_hitbox.bounds.top()
|
+ text_hitbox.bounds.top()
|
||||||
|
@ -5214,7 +5210,7 @@ impl EditorElement {
|
||||||
let intersects_menu = |bounds: Bounds<Pixels>| -> bool {
|
let intersects_menu = |bounds: Bounds<Pixels>| -> bool {
|
||||||
context_menu_layout
|
context_menu_layout
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_or(false, |menu| bounds.intersects(&menu.bounds))
|
.is_some_and(|menu| bounds.intersects(&menu.bounds))
|
||||||
};
|
};
|
||||||
|
|
||||||
let final_origin = if popover_bounds_above.is_contained_within(hitbox)
|
let final_origin = if popover_bounds_above.is_contained_within(hitbox)
|
||||||
|
@ -5299,7 +5295,7 @@ impl EditorElement {
|
||||||
let mut end_row = start_row.0;
|
let mut end_row = start_row.0;
|
||||||
while active_rows
|
while active_rows
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(false, |(active_row, has_selection)| {
|
.is_some_and(|(active_row, has_selection)| {
|
||||||
active_row.0 == end_row + 1
|
active_row.0 == end_row + 1
|
||||||
&& has_selection.selection == contains_non_empty_selection.selection
|
&& has_selection.selection == contains_non_empty_selection.selection
|
||||||
})
|
})
|
||||||
|
@ -6687,25 +6683,23 @@ impl EditorElement {
|
||||||
editor.set_scroll_position(position, window, cx);
|
editor.set_scroll_position(position, window, cx);
|
||||||
}
|
}
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
} else {
|
} else if minimap_hitbox.is_hovered(window) {
|
||||||
if minimap_hitbox.is_hovered(window) {
|
editor.scroll_manager.set_is_hovering_minimap_thumb(
|
||||||
editor.scroll_manager.set_is_hovering_minimap_thumb(
|
!event.dragging()
|
||||||
!event.dragging()
|
&& layout
|
||||||
&& layout
|
.thumb_layout
|
||||||
.thumb_layout
|
.thumb_bounds
|
||||||
.thumb_bounds
|
.is_some_and(|bounds| bounds.contains(&event.position)),
|
||||||
.is_some_and(|bounds| bounds.contains(&event.position)),
|
cx,
|
||||||
cx,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
// Stop hover events from propagating to the
|
// Stop hover events from propagating to the
|
||||||
// underlying editor if the minimap hitbox is hovered
|
// underlying editor if the minimap hitbox is hovered
|
||||||
if !event.dragging() {
|
if !event.dragging() {
|
||||||
cx.stop_propagation();
|
cx.stop_propagation();
|
||||||
}
|
|
||||||
} else {
|
|
||||||
editor.scroll_manager.hide_minimap_thumb(cx);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
editor.scroll_manager.hide_minimap_thumb(cx);
|
||||||
}
|
}
|
||||||
mouse_position = event.position;
|
mouse_position = event.position;
|
||||||
});
|
});
|
||||||
|
@ -7084,9 +7078,7 @@ impl EditorElement {
|
||||||
let unstaged_hollow = ProjectSettings::get_global(cx)
|
let unstaged_hollow = ProjectSettings::get_global(cx)
|
||||||
.git
|
.git
|
||||||
.hunk_style
|
.hunk_style
|
||||||
.map_or(false, |style| {
|
.is_some_and(|style| matches!(style, GitHunkStyleSetting::UnstagedHollow));
|
||||||
matches!(style, GitHunkStyleSetting::UnstagedHollow)
|
|
||||||
});
|
|
||||||
|
|
||||||
unstaged == unstaged_hollow
|
unstaged == unstaged_hollow
|
||||||
}
|
}
|
||||||
|
@ -8183,7 +8175,7 @@ impl Element for EditorElement {
|
||||||
let is_row_soft_wrapped = |row: usize| {
|
let is_row_soft_wrapped = |row: usize| {
|
||||||
row_infos
|
row_infos
|
||||||
.get(row)
|
.get(row)
|
||||||
.map_or(true, |info| info.buffer_row.is_none())
|
.is_none_or(|info| info.buffer_row.is_none())
|
||||||
};
|
};
|
||||||
|
|
||||||
let start_anchor = if start_row == Default::default() {
|
let start_anchor = if start_row == Default::default() {
|
||||||
|
@ -9718,14 +9710,12 @@ impl PointForPosition {
|
||||||
false
|
false
|
||||||
} else if start_row == end_row {
|
} else if start_row == end_row {
|
||||||
candidate_col >= start_col && candidate_col < end_col
|
candidate_col >= start_col && candidate_col < end_col
|
||||||
|
} else if candidate_row == start_row {
|
||||||
|
candidate_col >= start_col
|
||||||
|
} else if candidate_row == end_row {
|
||||||
|
candidate_col < end_col
|
||||||
} else {
|
} else {
|
||||||
if candidate_row == start_row {
|
true
|
||||||
candidate_col >= start_col
|
|
||||||
} else if candidate_row == end_row {
|
|
||||||
candidate_col < end_col
|
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -415,7 +415,7 @@ impl GitBlame {
|
||||||
let old_end = cursor.end();
|
let old_end = cursor.end();
|
||||||
if row_edits
|
if row_edits
|
||||||
.peek()
|
.peek()
|
||||||
.map_or(true, |next_edit| next_edit.old.start >= old_end)
|
.is_none_or(|next_edit| next_edit.old.start >= old_end)
|
||||||
&& let Some(entry) = cursor.item()
|
&& let Some(entry) = cursor.item()
|
||||||
{
|
{
|
||||||
if old_end > edit.old.end {
|
if old_end > edit.old.end {
|
||||||
|
|
|
@ -271,7 +271,7 @@ impl Editor {
|
||||||
Task::ready(Ok(Navigated::No))
|
Task::ready(Ok(Navigated::No))
|
||||||
};
|
};
|
||||||
self.select(SelectPhase::End, window, cx);
|
self.select(SelectPhase::End, window, cx);
|
||||||
return navigate_task;
|
navigate_task
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -871,7 +871,7 @@ fn surrounding_filename(
|
||||||
.peekable();
|
.peekable();
|
||||||
while let Some(ch) = forwards.next() {
|
while let Some(ch) = forwards.next() {
|
||||||
// Skip escaped whitespace
|
// Skip escaped whitespace
|
||||||
if ch == '\\' && forwards.peek().map_or(false, |ch| ch.is_whitespace()) {
|
if ch == '\\' && forwards.peek().is_some_and(|ch| ch.is_whitespace()) {
|
||||||
token_end += ch.len_utf8();
|
token_end += ch.len_utf8();
|
||||||
let whitespace = forwards.next().unwrap();
|
let whitespace = forwards.next().unwrap();
|
||||||
token_end += whitespace.len_utf8();
|
token_end += whitespace.len_utf8();
|
||||||
|
|
|
@ -201,7 +201,7 @@ impl FollowableItem for Editor {
|
||||||
if buffer
|
if buffer
|
||||||
.as_singleton()
|
.as_singleton()
|
||||||
.and_then(|buffer| buffer.read(cx).file())
|
.and_then(|buffer| buffer.read(cx).file())
|
||||||
.map_or(false, |file| file.is_private())
|
.is_some_and(|file| file.is_private())
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
@ -715,7 +715,7 @@ impl Item for Editor {
|
||||||
.read(cx)
|
.read(cx)
|
||||||
.as_singleton()
|
.as_singleton()
|
||||||
.and_then(|buffer| buffer.read(cx).file())
|
.and_then(|buffer| buffer.read(cx).file())
|
||||||
.map_or(false, |file| file.disk_state() == DiskState::Deleted);
|
.is_some_and(|file| file.disk_state() == DiskState::Deleted);
|
||||||
|
|
||||||
h_flex()
|
h_flex()
|
||||||
.gap_2()
|
.gap_2()
|
||||||
|
|
|
@ -86,9 +86,9 @@ pub(crate) fn should_auto_close(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if to_auto_edit.is_empty() {
|
if to_auto_edit.is_empty() {
|
||||||
return None;
|
None
|
||||||
} else {
|
} else {
|
||||||
return Some(to_auto_edit);
|
Some(to_auto_edit)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ pub(crate) fn generate_auto_close_edits(
|
||||||
let range = node_name.byte_range();
|
let range = node_name.byte_range();
|
||||||
return buffer.text_for_range(range).equals_str(name);
|
return buffer.text_for_range(range).equals_str(name);
|
||||||
}
|
}
|
||||||
return is_empty;
|
is_empty
|
||||||
};
|
};
|
||||||
|
|
||||||
let tree_root_node = {
|
let tree_root_node = {
|
||||||
|
@ -227,7 +227,7 @@ pub(crate) fn generate_auto_close_edits(
|
||||||
let has_open_tag_with_same_tag_name = ancestor
|
let has_open_tag_with_same_tag_name = ancestor
|
||||||
.named_child(0)
|
.named_child(0)
|
||||||
.filter(|n| n.kind() == config.open_tag_node_name)
|
.filter(|n| n.kind() == config.open_tag_node_name)
|
||||||
.map_or(false, |element_open_tag_node| {
|
.is_some_and(|element_open_tag_node| {
|
||||||
tag_node_name_equals(&element_open_tag_node, &tag_name)
|
tag_node_name_equals(&element_open_tag_node, &tag_name)
|
||||||
});
|
});
|
||||||
if has_open_tag_with_same_tag_name {
|
if has_open_tag_with_same_tag_name {
|
||||||
|
@ -263,8 +263,7 @@ pub(crate) fn generate_auto_close_edits(
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_after_open_tag = |node: &Node| {
|
let is_after_open_tag = |node: &Node| {
|
||||||
return node.start_byte() < open_tag.start_byte()
|
node.start_byte() < open_tag.start_byte() && node.end_byte() < open_tag.start_byte()
|
||||||
&& node.end_byte() < open_tag.start_byte();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// perf: use cursor for more efficient traversal
|
// perf: use cursor for more efficient traversal
|
||||||
|
@ -301,7 +300,7 @@ pub(crate) fn generate_auto_close_edits(
|
||||||
let edit_range = edit_anchor..edit_anchor;
|
let edit_range = edit_anchor..edit_anchor;
|
||||||
edits.push((edit_range, format!("</{}>", tag_name)));
|
edits.push((edit_range, format!("</{}>", tag_name)));
|
||||||
}
|
}
|
||||||
return Ok(edits);
|
Ok(edits)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn refresh_enabled_in_any_buffer(
|
pub(crate) fn refresh_enabled_in_any_buffer(
|
||||||
|
@ -367,7 +366,7 @@ pub(crate) fn construct_initial_buffer_versions_map<
|
||||||
initial_buffer_versions.insert(buffer_id, buffer_version);
|
initial_buffer_versions.insert(buffer_id, buffer_version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return initial_buffer_versions;
|
initial_buffer_versions
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn handle_from(
|
pub(crate) fn handle_from(
|
||||||
|
@ -455,12 +454,9 @@ pub(crate) fn handle_from(
|
||||||
let ensure_no_edits_since_start = || -> Option<()> {
|
let ensure_no_edits_since_start = || -> Option<()> {
|
||||||
let has_edits_since_start = this
|
let has_edits_since_start = this
|
||||||
.read_with(cx, |this, cx| {
|
.read_with(cx, |this, cx| {
|
||||||
this.buffer
|
this.buffer.read(cx).buffer(buffer_id).is_none_or(|buffer| {
|
||||||
.read(cx)
|
buffer.read(cx).has_edits_since(&buffer_version_initial)
|
||||||
.buffer(buffer_id)
|
})
|
||||||
.map_or(true, |buffer| {
|
|
||||||
buffer.read(cx).has_edits_since(&buffer_version_initial)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
|
|
|
@ -61,13 +61,13 @@ impl MouseContextMenu {
|
||||||
source,
|
source,
|
||||||
offset: position - (source_position + content_origin),
|
offset: position - (source_position + content_origin),
|
||||||
};
|
};
|
||||||
return Some(MouseContextMenu::new(
|
Some(MouseContextMenu::new(
|
||||||
editor,
|
editor,
|
||||||
menu_position,
|
menu_position,
|
||||||
context_menu,
|
context_menu,
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
));
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
|
|
|
@ -89,7 +89,7 @@ impl Editor {
|
||||||
.lsp_task_source()?;
|
.lsp_task_source()?;
|
||||||
if lsp_settings
|
if lsp_settings
|
||||||
.get(&lsp_tasks_source)
|
.get(&lsp_tasks_source)
|
||||||
.map_or(true, |s| s.enable_lsp_tasks)
|
.is_none_or(|s| s.enable_lsp_tasks)
|
||||||
{
|
{
|
||||||
let buffer_id = buffer.read(cx).remote_id();
|
let buffer_id = buffer.read(cx).remote_id();
|
||||||
Some((lsp_tasks_source, buffer_id))
|
Some((lsp_tasks_source, buffer_id))
|
||||||
|
|
|
@ -54,7 +54,7 @@ impl AssertionsReport {
|
||||||
pub fn passed_count(&self) -> usize {
|
pub fn passed_count(&self) -> usize {
|
||||||
self.ran
|
self.ran
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|a| a.result.as_ref().map_or(false, |result| result.passed))
|
.filter(|a| a.result.as_ref().is_ok_and(|result| result.passed))
|
||||||
.count()
|
.count()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ fn main() {
|
||||||
let telemetry = app_state.client.telemetry();
|
let telemetry = app_state.client.telemetry();
|
||||||
telemetry.start(system_id, installation_id, session_id, cx);
|
telemetry.start(system_id, installation_id, session_id, cx);
|
||||||
|
|
||||||
let enable_telemetry = env::var("ZED_EVAL_TELEMETRY").map_or(false, |value| value == "1")
|
let enable_telemetry = env::var("ZED_EVAL_TELEMETRY").is_ok_and(|value| value == "1")
|
||||||
&& telemetry.has_checksum_seed();
|
&& telemetry.has_checksum_seed();
|
||||||
if enable_telemetry {
|
if enable_telemetry {
|
||||||
println!("Telemetry enabled");
|
println!("Telemetry enabled");
|
||||||
|
|
|
@ -70,10 +70,10 @@ impl Example for AddArgToTraitMethod {
|
||||||
let path_str = format!("crates/assistant_tools/src/{}.rs", tool_name);
|
let path_str = format!("crates/assistant_tools/src/{}.rs", tool_name);
|
||||||
let edits = edits.get(Path::new(&path_str));
|
let edits = edits.get(Path::new(&path_str));
|
||||||
|
|
||||||
let ignored = edits.map_or(false, |edits| {
|
let ignored = edits.is_some_and(|edits| {
|
||||||
edits.has_added_line(" _window: Option<gpui::AnyWindowHandle>,\n")
|
edits.has_added_line(" _window: Option<gpui::AnyWindowHandle>,\n")
|
||||||
});
|
});
|
||||||
let uningored = edits.map_or(false, |edits| {
|
let uningored = edits.is_some_and(|edits| {
|
||||||
edits.has_added_line(" window: Option<gpui::AnyWindowHandle>,\n")
|
edits.has_added_line(" window: Option<gpui::AnyWindowHandle>,\n")
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ impl Example for AddArgToTraitMethod {
|
||||||
let batch_tool_edits = edits.get(Path::new("crates/assistant_tools/src/batch_tool.rs"));
|
let batch_tool_edits = edits.get(Path::new("crates/assistant_tools/src/batch_tool.rs"));
|
||||||
|
|
||||||
cx.assert(
|
cx.assert(
|
||||||
batch_tool_edits.map_or(false, |edits| {
|
batch_tool_edits.is_some_and(|edits| {
|
||||||
edits.has_added_line(" window: Option<gpui::AnyWindowHandle>,\n")
|
edits.has_added_line(" window: Option<gpui::AnyWindowHandle>,\n")
|
||||||
}),
|
}),
|
||||||
"Argument: batch_tool",
|
"Argument: batch_tool",
|
||||||
|
|
|
@ -401,7 +401,7 @@ impl ExtensionBuilder {
|
||||||
let mut clang_path = wasi_sdk_dir.clone();
|
let mut clang_path = wasi_sdk_dir.clone();
|
||||||
clang_path.extend(["bin", &format!("clang{}", env::consts::EXE_SUFFIX)]);
|
clang_path.extend(["bin", &format!("clang{}", env::consts::EXE_SUFFIX)]);
|
||||||
|
|
||||||
if fs::metadata(&clang_path).map_or(false, |metadata| metadata.is_file()) {
|
if fs::metadata(&clang_path).is_ok_and(|metadata| metadata.is_file()) {
|
||||||
return Ok(clang_path);
|
return Ok(clang_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@ pub struct ExtensionEvents;
|
||||||
impl ExtensionEvents {
|
impl ExtensionEvents {
|
||||||
/// Returns the global [`ExtensionEvents`].
|
/// Returns the global [`ExtensionEvents`].
|
||||||
pub fn try_global(cx: &App) -> Option<Entity<Self>> {
|
pub fn try_global(cx: &App) -> Option<Entity<Self>> {
|
||||||
return cx
|
cx.try_global::<GlobalExtensionEvents>()
|
||||||
.try_global::<GlobalExtensionEvents>()
|
.map(|g| g.0.clone())
|
||||||
.map(|g| g.0.clone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(_cx: &mut Context<Self>) -> Self {
|
fn new(_cx: &mut Context<Self>) -> Self {
|
||||||
|
|
|
@ -562,12 +562,12 @@ impl ExtensionStore {
|
||||||
extensions
|
extensions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|extension| {
|
.filter(|extension| {
|
||||||
this.extension_index.extensions.get(&extension.id).map_or(
|
this.extension_index
|
||||||
true,
|
.extensions
|
||||||
|installed_extension| {
|
.get(&extension.id)
|
||||||
|
.is_none_or(|installed_extension| {
|
||||||
installed_extension.manifest.version != extension.manifest.version
|
installed_extension.manifest.version != extension.manifest.version
|
||||||
},
|
})
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
|
@ -1451,7 +1451,7 @@ impl ExtensionStore {
|
||||||
|
|
||||||
if extension_dir
|
if extension_dir
|
||||||
.file_name()
|
.file_name()
|
||||||
.map_or(false, |file_name| file_name == ".DS_Store")
|
.is_some_and(|file_name| file_name == ".DS_Store")
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ struct FeatureFlags {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static ZED_DISABLE_STAFF: LazyLock<bool> = LazyLock::new(|| {
|
pub static ZED_DISABLE_STAFF: LazyLock<bool> = LazyLock::new(|| {
|
||||||
std::env::var("ZED_DISABLE_STAFF").map_or(false, |value| !value.is_empty() && value != "0")
|
std::env::var("ZED_DISABLE_STAFF").is_ok_and(|value| !value.is_empty() && value != "0")
|
||||||
});
|
});
|
||||||
|
|
||||||
impl FeatureFlags {
|
impl FeatureFlags {
|
||||||
|
|
|
@ -135,7 +135,7 @@ impl Display for SystemSpecs {
|
||||||
fn try_determine_available_gpus() -> Option<String> {
|
fn try_determine_available_gpus() -> Option<String> {
|
||||||
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
|
||||||
{
|
{
|
||||||
return std::process::Command::new("vulkaninfo")
|
std::process::Command::new("vulkaninfo")
|
||||||
.args(&["--summary"])
|
.args(&["--summary"])
|
||||||
.output()
|
.output()
|
||||||
.ok()
|
.ok()
|
||||||
|
@ -150,11 +150,11 @@ fn try_determine_available_gpus() -> Option<String> {
|
||||||
]
|
]
|
||||||
.join("\n")
|
.join("\n")
|
||||||
})
|
})
|
||||||
.or(Some("Failed to run `vulkaninfo --summary`".to_string()));
|
.or(Some("Failed to run `vulkaninfo --summary`".to_string()))
|
||||||
}
|
}
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
|
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
|
||||||
{
|
{
|
||||||
return None;
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -878,9 +878,7 @@ impl FileFinderDelegate {
|
||||||
PathMatchCandidateSet {
|
PathMatchCandidateSet {
|
||||||
snapshot: worktree.snapshot(),
|
snapshot: worktree.snapshot(),
|
||||||
include_ignored: self.include_ignored.unwrap_or_else(|| {
|
include_ignored: self.include_ignored.unwrap_or_else(|| {
|
||||||
worktree
|
worktree.root_entry().is_some_and(|entry| entry.is_ignored)
|
||||||
.root_entry()
|
|
||||||
.map_or(false, |entry| entry.is_ignored)
|
|
||||||
}),
|
}),
|
||||||
include_root_name,
|
include_root_name,
|
||||||
candidates: project::Candidates::Files,
|
candidates: project::Candidates::Files,
|
||||||
|
|
|
@ -728,7 +728,7 @@ impl PickerDelegate for OpenPathDelegate {
|
||||||
.child(LabelLike::new().child(label_with_highlights)),
|
.child(LabelLike::new().child(label_with_highlights)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
DirectoryState::None { .. } => return None,
|
DirectoryState::None { .. } => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ impl FileIcons {
|
||||||
return maybe_path;
|
return maybe_path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.get_icon_for_type("default", cx);
|
this.get_icon_for_type("default", cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_icon_theme(cx: &App) -> Option<Arc<IconTheme>> {
|
fn default_icon_theme(cx: &App) -> Option<Arc<IconTheme>> {
|
||||||
|
|
|
@ -625,13 +625,13 @@ impl Fs for RealFs {
|
||||||
async fn is_file(&self, path: &Path) -> bool {
|
async fn is_file(&self, path: &Path) -> bool {
|
||||||
smol::fs::metadata(path)
|
smol::fs::metadata(path)
|
||||||
.await
|
.await
|
||||||
.map_or(false, |metadata| metadata.is_file())
|
.is_ok_and(|metadata| metadata.is_file())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn is_dir(&self, path: &Path) -> bool {
|
async fn is_dir(&self, path: &Path) -> bool {
|
||||||
smol::fs::metadata(path)
|
smol::fs::metadata(path)
|
||||||
.await
|
.await
|
||||||
.map_or(false, |metadata| metadata.is_dir())
|
.is_ok_and(|metadata| metadata.is_dir())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn metadata(&self, path: &Path) -> Result<Option<Metadata>> {
|
async fn metadata(&self, path: &Path) -> Result<Option<Metadata>> {
|
||||||
|
|
|
@ -269,10 +269,8 @@ impl GitExcludeOverride {
|
||||||
pub async fn restore_original(&mut self) -> Result<()> {
|
pub async fn restore_original(&mut self) -> Result<()> {
|
||||||
if let Some(ref original) = self.original_excludes {
|
if let Some(ref original) = self.original_excludes {
|
||||||
smol::fs::write(&self.git_exclude_path, original).await?;
|
smol::fs::write(&self.git_exclude_path, original).await?;
|
||||||
} else {
|
} else if self.git_exclude_path.exists() {
|
||||||
if self.git_exclude_path.exists() {
|
smol::fs::remove_file(&self.git_exclude_path).await?;
|
||||||
smol::fs::remove_file(&self.git_exclude_path).await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.added_excludes = None;
|
self.added_excludes = None;
|
||||||
|
@ -2052,7 +2050,7 @@ fn parse_branch_input(input: &str) -> Result<Vec<Branch>> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_upstream_track(upstream_track: &str) -> Result<UpstreamTracking> {
|
fn parse_upstream_track(upstream_track: &str) -> Result<UpstreamTracking> {
|
||||||
if upstream_track == "" {
|
if upstream_track.is_empty() {
|
||||||
return Ok(UpstreamTracking::Tracked(UpstreamTrackingStatus {
|
return Ok(UpstreamTracking::Tracked(UpstreamTrackingStatus {
|
||||||
ahead: 0,
|
ahead: 0,
|
||||||
behind: 0,
|
behind: 0,
|
||||||
|
|
|
@ -88,11 +88,10 @@ impl CommitView {
|
||||||
let ix = pane.items().position(|item| {
|
let ix = pane.items().position(|item| {
|
||||||
let commit_view = item.downcast::<CommitView>();
|
let commit_view = item.downcast::<CommitView>();
|
||||||
commit_view
|
commit_view
|
||||||
.map_or(false, |view| view.read(cx).commit.sha == commit.sha)
|
.is_some_and(|view| view.read(cx).commit.sha == commit.sha)
|
||||||
});
|
});
|
||||||
if let Some(ix) = ix {
|
if let Some(ix) = ix {
|
||||||
pane.activate_item(ix, true, true, window, cx);
|
pane.activate_item(ix, true, true, window, cx);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
pane.add_item(Box::new(commit_view), true, true, None, window, cx);
|
pane.add_item(Box::new(commit_view), true, true, None, window, cx);
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue