chore: Fix clippy::needless_borrow up to an editor

This commit is contained in:
Piotr Osiewicz 2024-01-21 14:55:08 +01:00
parent c3102feeeb
commit 6c82380232
29 changed files with 86 additions and 88 deletions

View File

@ -134,7 +134,7 @@ pub async fn stream_completion(
line: Result<String, io::Error>,
) -> Result<Option<OpenAIResponseStreamEvent>> {
if let Some(data) = line?.strip_prefix("data: ") {
let event = serde_json::from_str(&data)?;
let event = serde_json::from_str(data)?;
Ok(Some(event))
} else {
Ok(None)

View File

@ -1432,7 +1432,7 @@ impl Room {
let display = displays
.first()
.ok_or_else(|| anyhow!("no display found"))?;
let track = LocalVideoTrack::screen_share_for_display(&display);
let track = LocalVideoTrack::screen_share_for_display(display);
this.upgrade()
.ok_or_else(|| anyhow!("room was dropped"))?
.update(&mut cx, |this, _| {

View File

@ -86,11 +86,11 @@ pub struct ChannelPathsInsertGuard<'a> {
impl<'a> ChannelPathsInsertGuard<'a> {
pub fn note_changed(&mut self, channel_id: ChannelId, epoch: u64, version: &clock::Global) {
insert_note_changed(&mut self.channels_by_id, channel_id, epoch, &version);
insert_note_changed(self.channels_by_id, channel_id, epoch, version);
}
pub fn new_messages(&mut self, channel_id: ChannelId, message_id: u64) {
insert_new_message(&mut self.channels_by_id, channel_id, message_id)
insert_new_message(self.channels_by_id, channel_id, message_id)
}
pub fn insert(&mut self, channel_proto: proto::Channel) -> bool {
@ -131,8 +131,8 @@ impl<'a> ChannelPathsInsertGuard<'a> {
impl<'a> Drop for ChannelPathsInsertGuard<'a> {
fn drop(&mut self) {
self.channels_ordered.sort_by(|a, b| {
let a = channel_path_sorting_key(*a, &self.channels_by_id);
let b = channel_path_sorting_key(*b, &self.channels_by_id);
let a = channel_path_sorting_key(*a, self.channels_by_id);
let b = channel_path_sorting_key(*b, self.channels_by_id);
a.cmp(b)
});
self.channels_ordered.dedup();
@ -167,7 +167,7 @@ fn insert_note_changed(
if epoch > unseen_version.0 {
*unseen_version = (epoch, version.clone());
} else {
unseen_version.1.join(&version);
unseen_version.1.join(version);
}
}
}

View File

@ -1310,7 +1310,7 @@ impl Client {
drop(state);
if let Some(handler) = handler {
let future = handler(subscriber, message, &self, cx.clone());
let future = handler(subscriber, message, self, cx.clone());
let client_id = self.id();
log::debug!(
"rpc message received. client_id:{}, sender_id:{:?}, type:{}",

View File

@ -974,7 +974,7 @@ async fn get_copilot_lsp(http: Arc<dyn HttpClient>) -> anyhow::Result<PathBuf> {
.browser_download_url;
let mut response = http
.get(&url, Default::default(), true)
.get(url, Default::default(), true)
.await
.map_err(|err| anyhow!("error downloading copilot release: {}", err))?;
let decompressed_bytes = GzipDecoder::new(BufReader::new(response.body_mut()));

View File

@ -72,7 +72,7 @@ impl GitRepository for LibGitRepository {
// This check is required because index.get_path() unwraps internally :(
check_path_to_repo_path_errors(relative_file_path)?;
let oid = match index.get_path(&relative_file_path, STAGE_NORMAL) {
let oid = match index.get_path(relative_file_path, STAGE_NORMAL) {
Some(entry) => entry.id,
None => return Ok(None),
};
@ -81,7 +81,7 @@ impl GitRepository for LibGitRepository {
Ok(Some(String::from_utf8(content)?))
}
match logic(&self, relative_file_path) {
match logic(self, relative_file_path) {
Ok(value) => return value,
Err(err) => log::error!("Error loading head text: {:?}", err),
}
@ -199,7 +199,7 @@ impl GitRepository for LibGitRepository {
fn matches_index(repo: &LibGitRepository, path: &RepoPath, mtime: SystemTime) -> bool {
if let Some(index) = repo.index().log_err() {
if let Some(entry) = index.get_path(&path, 0) {
if let Some(entry) = index.get_path(path, 0) {
if let Some(mtime) = mtime.duration_since(SystemTime::UNIX_EPOCH).log_err() {
if entry.mtime.seconds() == mtime.as_secs() as i32
&& entry.mtime.nanoseconds() == mtime.subsec_nanos()

View File

@ -165,7 +165,7 @@ impl BufferDiff {
let mut tree = SumTree::new();
let buffer_text = buffer.as_rope().to_string();
let patch = Self::diff(&diff_base, &buffer_text);
let patch = Self::diff(diff_base, &buffer_text);
if let Some(patch) = patch {
let mut divergence = 0;

View File

@ -153,49 +153,49 @@ impl Scene {
for shadow in prev_scene.shadows.drain(..) {
if views.contains(&shadow.view_id.into()) {
let order = &prev_scene.orders_by_layer[&shadow.layer_id];
self.insert(&order, shadow);
self.insert(order, shadow);
}
}
for quad in prev_scene.quads.drain(..) {
if views.contains(&quad.view_id.into()) {
let order = &prev_scene.orders_by_layer[&quad.layer_id];
self.insert(&order, quad);
self.insert(order, quad);
}
}
for path in prev_scene.paths.drain(..) {
if views.contains(&path.view_id.into()) {
let order = &prev_scene.orders_by_layer[&path.layer_id];
self.insert(&order, path);
self.insert(order, path);
}
}
for underline in prev_scene.underlines.drain(..) {
if views.contains(&underline.view_id.into()) {
let order = &prev_scene.orders_by_layer[&underline.layer_id];
self.insert(&order, underline);
self.insert(order, underline);
}
}
for sprite in prev_scene.monochrome_sprites.drain(..) {
if views.contains(&sprite.view_id.into()) {
let order = &prev_scene.orders_by_layer[&sprite.layer_id];
self.insert(&order, sprite);
self.insert(order, sprite);
}
}
for sprite in prev_scene.polychrome_sprites.drain(..) {
if views.contains(&sprite.view_id.into()) {
let order = &prev_scene.orders_by_layer[&sprite.layer_id];
self.insert(&order, sprite);
self.insert(order, sprite);
}
}
for surface in prev_scene.surfaces.drain(..) {
if views.contains(&surface.view_id.into()) {
let order = &prev_scene.orders_by_layer[&surface.layer_id];
self.insert(&order, surface);
self.insert(order, surface);
}
}
}

View File

@ -3007,7 +3007,7 @@ impl BufferSnapshot {
groups.sort_by(|(id_a, group_a), (id_b, group_b)| {
let a_start = &group_a.entries[group_a.primary_ix].range.start;
let b_start = &group_b.entries[group_b.primary_ix].range.start;
a_start.cmp(b_start, self).then_with(|| id_a.cmp(&id_b))
a_start.cmp(b_start, self).then_with(|| id_a.cmp(id_b))
});
groups

View File

@ -194,7 +194,7 @@ impl DiagnosticSet {
.range
.start
.cmp(&group_b.entries[group_b.primary_ix].range.start, buffer)
.then_with(|| id_a.cmp(&id_b))
.then_with(|| id_a.cmp(id_b))
});
}

View File

@ -852,7 +852,7 @@ impl LanguageRegistry {
let mut state = self.state.write();
state.theme = Some(theme.clone());
for language in &state.languages {
language.set_theme(&theme.syntax());
language.set_theme(theme.syntax());
}
}
@ -1166,7 +1166,7 @@ impl LanguageRegistryState {
fn add(&mut self, language: Arc<Language>) {
if let Some(theme) = self.theme.as_ref() {
language.set_theme(&theme.syntax());
language.set_theme(theme.syntax());
}
self.languages.push(language);
self.version += 1;

View File

@ -428,7 +428,7 @@ impl settings::Settings for AllLanguageSettings {
let mut languages = HashMap::default();
for (language_name, settings) in &default_value.languages {
let mut language_settings = defaults.clone();
merge_settings(&mut language_settings, &settings);
merge_settings(&mut language_settings, settings);
languages.insert(language_name.clone(), language_settings);
}
@ -468,7 +468,7 @@ impl settings::Settings for AllLanguageSettings {
languages
.entry(language_name.clone())
.or_insert_with(|| defaults.clone()),
&user_language_settings,
user_language_settings,
);
}
}

View File

@ -155,7 +155,7 @@ pub async fn parse_markdown_block(
let mut current_language = None;
let mut list_stack = Vec::new();
for event in Parser::new_ext(&markdown, Options::all()) {
for event in Parser::new_ext(markdown, Options::all()) {
let prev_len = text.len();
match event {
Event::Text(t) => {

View File

@ -283,7 +283,7 @@ impl SyntaxSnapshot {
depth,
position: edit_range.start,
};
if target.cmp(&cursor.start(), text).is_gt() {
if target.cmp(cursor.start(), text).is_gt() {
let slice = cursor.slice(&target, Bias::Left, text);
layers.append(slice, text);
}
@ -368,7 +368,7 @@ impl SyntaxSnapshot {
cursor.next(text);
}
layers.append(cursor.suffix(&text), &text);
layers.append(cursor.suffix(text), text);
drop(cursor);
self.layers = layers;
}
@ -433,7 +433,7 @@ impl SyntaxSnapshot {
let max_depth = self.layers.summary().max_depth;
let mut cursor = self.layers.cursor::<SyntaxLayerSummary>();
cursor.next(&text);
cursor.next(text);
let mut layers = SumTree::new();
let mut changed_regions = ChangeRegionSet::default();
@ -471,17 +471,17 @@ impl SyntaxSnapshot {
};
let mut done = cursor.item().is_none();
while !done && position.cmp(&cursor.end(text), &text).is_gt() {
while !done && position.cmp(&cursor.end(text), text).is_gt() {
done = true;
let bounded_position = SyntaxLayerPositionBeforeChange {
position: position.clone(),
change: changed_regions.start_position(),
};
if bounded_position.cmp(&cursor.start(), &text).is_gt() {
if bounded_position.cmp(cursor.start(), text).is_gt() {
let slice = cursor.slice(&bounded_position, Bias::Left, text);
if !slice.is_empty() {
layers.append(slice, &text);
layers.append(slice, text);
if changed_regions.prune(cursor.end(text), text) {
done = false;
}
@ -491,7 +491,7 @@ impl SyntaxSnapshot {
while position.cmp(&cursor.end(text), text).is_gt() {
let Some(layer) = cursor.item() else { break };
if changed_regions.intersects(&layer, text) {
if changed_regions.intersects(layer, text) {
if let SyntaxLayerContent::Parsed { language, .. } = &layer.content {
log::trace!(
"discard layer. language:{}, range:{:?}. changed_regions:{:?}",
@ -529,7 +529,7 @@ impl SyntaxSnapshot {
if layer.range.to_offset(text) == (step_start_byte..step_end_byte)
&& layer.content.language_id() == step.language.id()
{
cursor.next(&text);
cursor.next(text);
} else {
old_layer = None;
}
@ -561,7 +561,7 @@ impl SyntaxSnapshot {
log::trace!(
"existing layer. language:{}, start:{:?}, ranges:{:?}",
language.name(),
LogPoint(layer_start.to_point(&text)),
LogPoint(layer_start.to_point(text)),
LogIncludedRanges(&old_tree.included_ranges())
);
@ -584,7 +584,7 @@ impl SyntaxSnapshot {
insert_newlines_between_ranges(
changed_indices,
&mut included_ranges,
&text,
text,
step_start_byte,
step_start_point,
);
@ -701,7 +701,7 @@ impl SyntaxSnapshot {
range: step.range,
content,
},
&text,
text,
);
}
@ -860,7 +860,7 @@ impl<'a> SyntaxMapCaptures<'a> {
Some(grammar) => grammar,
None => continue,
};
let query = match query(&grammar) {
let query = match query(grammar) {
Some(query) => query,
None => continue,
};
@ -978,7 +978,7 @@ impl<'a> SyntaxMapMatches<'a> {
Some(grammar) => grammar,
None => continue,
};
let query = match query(&grammar) {
let query = match query(grammar) {
Some(query) => query,
None => continue,
};
@ -1087,7 +1087,7 @@ impl<'a> SyntaxMapMatchesLayer<'a> {
fn advance(&mut self) {
if let Some(mat) = self.matches.next() {
self.next_captures.clear();
self.next_captures.extend_from_slice(&mat.captures);
self.next_captures.extend_from_slice(mat.captures);
self.next_pattern_index = mat.pattern_index;
self.has_next = true;
} else {
@ -1517,7 +1517,7 @@ impl Eq for ParseStep {}
impl PartialOrd for ParseStep {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(&other))
Some(self.cmp(other))
}
}

View File

@ -345,7 +345,7 @@ impl LanguageServer {
if let Some(handler) = notification_handlers.lock().get_mut(msg.method) {
handler(
msg.id,
&msg.params.map(|params| params.get()).unwrap_or("null"),
msg.params.map(|params| params.get()).unwrap_or("null"),
cx.clone(),
);
} else {

View File

@ -2316,7 +2316,7 @@ impl MultiBufferSnapshot {
&self,
point: T,
) -> Option<(&BufferSnapshot, usize)> {
let offset = point.to_offset(&self);
let offset = point.to_offset(self);
let mut cursor = self.excerpts.cursor::<usize>();
cursor.seek(&offset, Bias::Right, &());
if cursor.item().is_none() {
@ -3694,7 +3694,7 @@ impl ExcerptId {
pub fn cmp(&self, other: &Self, snapshot: &MultiBufferSnapshot) -> cmp::Ordering {
let a = snapshot.excerpt_locator_for_id(*self);
let b = snapshot.excerpt_locator_for_id(*other);
a.cmp(&b).then_with(|| self.0.cmp(&other.0))
a.cmp(b).then_with(|| self.0.cmp(&other.0))
}
}

View File

@ -1532,7 +1532,7 @@ impl LspCommand for GetCompletions {
.iter()
.map(language::proto::serialize_completion)
.collect(),
version: serialize_version(&buffer_version),
version: serialize_version(buffer_version),
}
}
@ -1672,7 +1672,7 @@ impl LspCommand for GetCodeActions {
.iter()
.map(language::proto::serialize_code_action)
.collect(),
version: serialize_version(&buffer_version),
version: serialize_version(buffer_version),
}
}

View File

@ -2947,7 +2947,7 @@ impl Project {
};
task.await;
this.update(&mut cx, |this, mut cx| {
this.update(&mut cx, |this, cx| {
let worktrees = this.worktrees.clone();
for worktree in worktrees {
let worktree = match worktree.upgrade() {
@ -2962,7 +2962,7 @@ impl Project {
root_path,
adapter.clone(),
language.clone(),
&mut cx,
cx,
);
}
})
@ -3544,8 +3544,8 @@ impl Project {
if errored {
log::warn!("test binary check failed");
let task = this
.update(&mut cx, move |this, mut cx| {
this.reinstall_language_server(language, adapter, server_id, &mut cx)
.update(&mut cx, move |this, cx| {
this.reinstall_language_server(language, adapter, server_id, cx)
})
.ok()
.flatten();
@ -3768,8 +3768,7 @@ impl Project {
}
};
if let Some(relative_glob_pattern) = relative_glob_pattern {
let literal_prefix =
glob_literal_prefix(&relative_glob_pattern);
let literal_prefix = glob_literal_prefix(relative_glob_pattern);
tree.as_local_mut()
.unwrap()
.add_path_prefix_to_scan(Path::new(literal_prefix).into());
@ -4231,9 +4230,9 @@ impl Project {
format_operation = Some(FormatOperation::Lsp(
Self::format_via_lsp(
&project,
&buffer,
buffer,
buffer_abs_path,
&language_server,
language_server,
tab_size,
&mut cx,
)
@ -4252,8 +4251,8 @@ impl Project {
format_operation = Self::format_via_external_command(
buffer,
buffer_abs_path,
&command,
&arguments,
command,
arguments,
&mut cx,
)
.await
@ -4276,9 +4275,9 @@ impl Project {
format_operation = Some(FormatOperation::Lsp(
Self::format_via_lsp(
&project,
&buffer,
buffer,
buffer_abs_path,
&language_server,
language_server,
tab_size,
&mut cx,
)
@ -5847,7 +5846,7 @@ impl Project {
snapshot.file().map(|file| file.path().as_ref()),
) {
query
.search(&snapshot, None)
.search(snapshot, None)
.await
.iter()
.map(|range| {
@ -6690,7 +6689,7 @@ impl Project {
snapshot.repository_and_work_directory_for_path(&path)?;
let repo = snapshot.get_local_repo(&repo)?;
let relative_path = path.strip_prefix(&work_directory).ok()?;
let base_text = repo.repo_ptr.lock().load_index_text(&relative_path);
let base_text = repo.repo_ptr.lock().load_index_text(relative_path);
Some((buffer, base_text))
})
.collect::<Vec<_>>()
@ -6823,7 +6822,7 @@ impl Project {
for (_, _, path_summary) in
self.diagnostic_summaries(include_ignored, cx)
.filter(|(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
let worktree = self.entry_for_path(path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
{
@ -6849,7 +6848,7 @@ impl Project {
})
})
.filter(move |(path, _, _)| {
let worktree = self.entry_for_path(&path, cx).map(|entry| entry.is_ignored);
let worktree = self.entry_for_path(path, cx).map(|entry| entry.is_ignored);
include_ignored || worktree == Some(false)
})
}

View File

@ -61,7 +61,7 @@ impl Project {
if let Some(python_settings) = &python_settings.as_option() {
let activate_script_path =
self.find_activate_script_path(&python_settings, working_directory);
self.find_activate_script_path(python_settings, working_directory);
self.activate_python_virtual_environment(
activate_script_path,
&terminal_handle,

View File

@ -1437,7 +1437,7 @@ impl LocalWorktree {
if let Err(e) = self.client.send(proto::UpdateDiagnosticSummary {
project_id,
worktree_id: cx.entity_id().as_u64(),
summary: Some(summary.to_proto(server_id, &path)),
summary: Some(summary.to_proto(server_id, path)),
}) {
return Task::ready(Err(e));
}
@ -2309,7 +2309,7 @@ impl LocalSnapshot {
impl BackgroundScannerState {
fn should_scan_directory(&self, entry: &Entry) -> bool {
(!entry.is_external && !entry.is_ignored)
|| entry.path.file_name() == Some(&*DOT_GIT)
|| entry.path.file_name() == Some(*DOT_GIT)
|| self.scanned_dirs.contains(&entry.id) // If we've ever scanned it, keep scanning
|| self
.paths_to_scan
@ -3374,7 +3374,7 @@ impl BackgroundScanner {
let mut is_git_related = false;
if let Some(dot_git_dir) = abs_path
.ancestors()
.find(|ancestor| ancestor.file_name() == Some(&*DOT_GIT))
.find(|ancestor| ancestor.file_name() == Some(*DOT_GIT))
{
let dot_git_path = dot_git_dir
.strip_prefix(&root_canonical_path)
@ -3772,7 +3772,7 @@ impl BackgroundScanner {
for entry in &mut new_entries {
state.reuse_entry_id(entry);
if entry.is_dir() {
if state.should_scan_directory(&entry) {
if state.should_scan_directory(entry) {
job_ix += 1;
} else {
log::debug!("defer scanning directory {:?}", entry.path);
@ -3814,9 +3814,9 @@ impl BackgroundScanner {
abs_paths
.iter()
.map(|abs_path| async move {
let metadata = self.fs.metadata(&abs_path).await?;
let metadata = self.fs.metadata(abs_path).await?;
if let Some(metadata) = metadata {
let canonical_path = self.fs.canonicalize(&abs_path).await?;
let canonical_path = self.fs.canonicalize(abs_path).await?;
anyhow::Ok(Some((metadata, canonical_path)))
} else {
Ok(None)
@ -3864,7 +3864,7 @@ impl BackgroundScanner {
fs_entry.is_external = !canonical_path.starts_with(&root_canonical_path);
if !is_dir && !fs_entry.is_ignored {
if let Some((work_dir, repo)) = state.snapshot.local_repo_for_path(&path) {
if let Some((work_dir, repo)) = state.snapshot.local_repo_for_path(path) {
if let Ok(repo_path) = path.strip_prefix(work_dir.0) {
let repo_path = RepoPath(repo_path.into());
let repo = repo.repo_ptr.lock();
@ -3884,7 +3884,7 @@ impl BackgroundScanner {
state.insert_entry(fs_entry, self.fs.as_ref());
}
Ok(None) => {
self.remove_repo_path(&path, &mut state.snapshot);
self.remove_repo_path(path, &mut state.snapshot);
}
Err(err) => {
// TODO - create a special 'error' entry in the entries tree to mark this

View File

@ -65,7 +65,7 @@ impl RichText {
},
Highlight::Id(id) => HighlightStyle {
background_color: Some(code_background),
..id.style(&theme.syntax()).unwrap_or_default()
..id.style(theme.syntax()).unwrap_or_default()
},
Highlight::Highlight(highlight) => *highlight,
Highlight::Mention => HighlightStyle {
@ -120,7 +120,7 @@ pub fn render_markdown_mut(
let mut list_stack = Vec::new();
let options = Options::all();
for (event, source_range) in Parser::new_ext(&block, options).into_offset_iter() {
for (event, source_range) in Parser::new_ext(block, options).into_offset_iter() {
let prev_len = text.len();
match event {
Event::Text(t) => {

View File

@ -533,7 +533,7 @@ impl SettingsStore {
}
if let Some(local_settings) =
setting_value.deserialize_setting(&local_settings).log_err()
setting_value.deserialize_setting(local_settings).log_err()
{
paths_stack.push(Some((*root_id, path.as_ref())));
user_settings_stack.push(local_settings);
@ -697,8 +697,7 @@ fn update_value_in_json_text<'a>(
if let Some(new_object) = new_value.as_object_mut() {
new_object.retain(|_, v| !v.is_null());
}
let (range, replacement) =
replace_value_in_json_text(text, &key_path, tab_size, &new_value);
let (range, replacement) = replace_value_in_json_text(text, key_path, tab_size, &new_value);
text.replace_range(range.clone(), &replacement);
edits.push((range, replacement));
}

View File

@ -1210,7 +1210,7 @@ impl Terminal {
pub fn scroll_wheel(&mut self, e: &ScrollWheelEvent, origin: Point<Pixels>) {
let mouse_mode = self.mouse_mode(e.shift);
if let Some(scroll_lines) = self.determine_scroll_lines(&e, mouse_mode) {
if let Some(scroll_lines) = self.determine_scroll_lines(e, mouse_mode) {
if mouse_mode {
let point = grid_point(
e.position - origin,
@ -1219,7 +1219,7 @@ impl Terminal {
);
if let Some(scrolls) =
scroll_report(point, scroll_lines as i32, &e, self.last_content.mode)
scroll_report(point, scroll_lines as i32, e, self.last_content.mode)
{
for scroll in scrolls {
self.pty_tx.notify(scroll);
@ -1299,7 +1299,7 @@ impl Terminal {
"{}{}",
fpi.name,
if fpi.argv.len() >= 1 {
format!(" {}", (&fpi.argv[1..]).join(" "))
format!(" {}", (fpi.argv[1..]).join(" "))
} else {
"".to_string()
}

View File

@ -16,7 +16,7 @@ impl RenderOnce for KeyBinding {
.flex_none()
.gap_2()
.children(self.key_binding.keystrokes().iter().map(|keystroke| {
let key_icon = Self::icon_for_key(&keystroke);
let key_icon = Self::icon_for_key(keystroke);
h_flex()
.flex_none()

View File

@ -51,7 +51,7 @@ impl<M: ManagedView> PopoverMenu<M> {
cx.subscribe(&new_menu, move |modal, _: &DismissEvent, cx| {
if modal.focus_handle(cx).contains_focused(cx) {
if previous_focus_handle.is_some() {
cx.focus(&previous_focus_handle.as_ref().unwrap())
cx.focus(previous_focus_handle.as_ref().unwrap())
}
}
*menu2.borrow_mut() = None;

View File

@ -155,7 +155,7 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
cx.subscribe(&new_menu, move |modal, _: &DismissEvent, cx| {
if modal.focus_handle(cx).contains_focused(cx) {
if previous_focus_handle.is_some() {
cx.focus(&previous_focus_handle.as_ref().unwrap())
cx.focus(previous_focus_handle.as_ref().unwrap())
}
}
*menu2.borrow_mut() = None;

View File

@ -2054,7 +2054,7 @@ fn dirty_message_for(buffer_path: Option<ProjectPath>) -> String {
let path = buffer_path
.as_ref()
.and_then(|p| p.path.to_str())
.unwrap_or(&"This buffer");
.unwrap_or("This buffer");
let path = truncate_and_remove_front(path, 80);
format!("{path} contains unsaved edits. Do you want to save it?")
}

View File

@ -591,7 +591,7 @@ impl WorkspaceDb {
Ok(())
}
SerializedPaneGroup::Pane(pane) => {
Self::save_pane(conn, workspace_id, &pane, parent)?;
Self::save_pane(conn, workspace_id, pane, parent)?;
Ok(())
}
}

View File

@ -728,7 +728,7 @@ impl Workspace {
cx.spawn(|mut cx| async move {
let serialized_workspace: Option<SerializedWorkspace> =
persistence::DB.workspace_for_roots(&abs_paths.as_slice());
persistence::DB.workspace_for_roots(abs_paths.as_slice());
let paths_to_open = Arc::new(abs_paths);
@ -3034,7 +3034,7 @@ impl Workspace {
flexes: Some(flexes.lock().clone()),
},
Member::Pane(pane_handle) => {
SerializedPaneGroup::Pane(serialize_pane_handle(&pane_handle, cx))
SerializedPaneGroup::Pane(serialize_pane_handle(pane_handle, cx))
}
}
}
@ -4228,7 +4228,7 @@ pub fn restart(_: &Restart, cx: &mut AppContext) {
// If multiple windows have unsaved changes, and need a save prompt,
// prompt in the active window before switching to a different window.
workspace_windows.sort_by_key(|window| window.is_active(&cx) == Some(false));
workspace_windows.sort_by_key(|window| window.is_active(cx) == Some(false));
let mut prompt = None;
if let (true, Some(window)) = (should_confirm, workspace_windows.first()) {