Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from zed-industries:main #58

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/icons/zed_predict_bg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 28 additions & 13 deletions crates/editor/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ use element::{AcceptEditPredictionBinding, LineWithInvisibles, PositionMap};
pub use element::{
CursorLayout, EditorElement, HighlightedRange, HighlightedRangeLine, PointForPosition,
};
use futures::{future, FutureExt};
use futures::{
future::{self, Shared},
FutureExt,
};
use fuzzy::StringMatchCandidate;

use code_context_menus::{
Expand Down Expand Up @@ -761,6 +764,7 @@ pub struct Editor {
next_scroll_position: NextScrollCursorCenterTopBottom,
addons: HashMap<TypeId, Box<dyn Addon>>,
registered_buffers: HashMap<BufferId, OpenLspBufferHandle>,
load_diff_task: Option<Shared<Task<()>>>,
selection_mark_mode: bool,
toggle_fold_multiple_buffers: Task<()>,
_scroll_cursor_center_top_bottom_task: Task<()>,
Expand Down Expand Up @@ -1318,12 +1322,16 @@ impl Editor {
};

let mut code_action_providers = Vec::new();
let mut load_uncommitted_diff = None;
if let Some(project) = project.clone() {
get_uncommitted_diff_for_buffer(
&project,
buffer.read(cx).all_buffers(),
buffer.clone(),
cx,
load_uncommitted_diff = Some(
get_uncommitted_diff_for_buffer(
&project,
buffer.read(cx).all_buffers(),
buffer.clone(),
cx,
)
.shared(),
);
code_action_providers.push(Rc::new(project) as Rc<_>);
}
Expand Down Expand Up @@ -1471,6 +1479,7 @@ impl Editor {
selection_mark_mode: false,
toggle_fold_multiple_buffers: Task::ready(()),
text_style_refinement: None,
load_diff_task: load_uncommitted_diff,
};
this.tasks_update_task = Some(this.refresh_runnables(window, cx));
this._subscriptions.extend(project_subscriptions);
Expand Down Expand Up @@ -14120,11 +14129,14 @@ impl Editor {
let buffer_id = buffer.read(cx).remote_id();
if self.buffer.read(cx).diff_for(buffer_id).is_none() {
if let Some(project) = &self.project {
get_uncommitted_diff_for_buffer(
project,
[buffer.clone()],
self.buffer.clone(),
cx,
self.load_diff_task = Some(
get_uncommitted_diff_for_buffer(
project,
[buffer.clone()],
self.buffer.clone(),
cx,
)
.shared(),
);
}
}
Expand Down Expand Up @@ -14879,14 +14891,18 @@ impl Editor {

gpui::Size::new(em_width, line_height)
}

pub fn wait_for_diff_to_load(&self) -> Option<Shared<Task<()>>> {
self.load_diff_task.clone()
}
}

fn get_uncommitted_diff_for_buffer(
project: &Entity<Project>,
buffers: impl IntoIterator<Item = Entity<Buffer>>,
buffer: Entity<MultiBuffer>,
cx: &mut App,
) {
) -> Task<()> {
let mut tasks = Vec::new();
project.update(cx, |project, cx| {
for buffer in buffers {
Expand All @@ -14903,7 +14919,6 @@ fn get_uncommitted_diff_for_buffer(
})
.ok();
})
.detach();
}

fn char_len_with_expanded_tabs(offset: usize, text: &str, tab_size: NonZeroU32) -> usize {
Expand Down
4 changes: 2 additions & 2 deletions crates/git_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ path = "src/git_ui.rs"

[dependencies]
anyhow.workspace = true
buffer_diff.workspace = true
collections.workspace = true
db.workspace = true
buffer_diff.workspace = true
editor.workspace = true
feature_flags.workspace = true
futures.workspace = true
fuzzy.workspace = true
git.workspace = true
gpui.workspace = true
itertools.workspace = true
language.workspace = true
menu.workspace = true
multi_buffer.workspace = true
Expand All @@ -37,7 +38,6 @@ serde_json.workspace = true
settings.workspace = true
theme.workspace = true
time.workspace = true
time_format.workspace = true
ui.workspace = true
util.workspace = true
workspace.workspace = true
Expand Down
Loading