Utilize initial file contents as head text by default
Co-Authored-By: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
parent
a679557e40
commit
632f47930f
2 changed files with 25 additions and 5 deletions
|
@ -32,6 +32,7 @@ use postage::{
|
||||||
prelude::{Sink as _, Stream as _},
|
prelude::{Sink as _, Stream as _},
|
||||||
watch,
|
watch,
|
||||||
};
|
};
|
||||||
|
use settings::Settings;
|
||||||
use smol::channel::{self, Sender};
|
use smol::channel::{self, Sender};
|
||||||
use std::{
|
use std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
|
@ -571,14 +572,33 @@ impl LocalWorktree {
|
||||||
let path = Arc::from(path);
|
let path = Arc::from(path);
|
||||||
let abs_path = self.absolutize(&path);
|
let abs_path = self.absolutize(&path);
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
|
|
||||||
|
let files_included = cx
|
||||||
|
.global::<Settings>()
|
||||||
|
.editor_overrides
|
||||||
|
.git_gutter
|
||||||
|
.unwrap_or_default()
|
||||||
|
.files_included;
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
let text = fs.load(&abs_path).await?;
|
let text = fs.load(&abs_path).await?;
|
||||||
|
|
||||||
let head_text = {
|
let head_text = if matches!(
|
||||||
|
files_included,
|
||||||
|
settings::GitFilesIncluded::All | settings::GitFilesIncluded::OnlyTracked
|
||||||
|
) {
|
||||||
let fs = fs.clone();
|
let fs = fs.clone();
|
||||||
let abs_path = abs_path.clone();
|
let abs_path = abs_path.clone();
|
||||||
let task = async move { fs.load_head_text(&abs_path).await };
|
let task = async move { fs.load_head_text(&abs_path).await };
|
||||||
cx.background().spawn(task).await
|
let results = cx.background().spawn(task).await;
|
||||||
|
|
||||||
|
if files_included == settings::GitFilesIncluded::All {
|
||||||
|
results.or_else(|| Some(text.clone()))
|
||||||
|
} else {
|
||||||
|
results
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
// Eagerly populate the snapshot with an updated entry for the loaded file
|
// Eagerly populate the snapshot with an updated entry for the loaded file
|
||||||
|
|
|
@ -66,13 +66,13 @@ pub struct EditorSettings {
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
||||||
pub struct GitGutterConfig {
|
pub struct GitGutterConfig {
|
||||||
pub files_included: GitGutterLevel,
|
pub files_included: GitFilesIncluded,
|
||||||
pub debounce_delay_millis: Option<u64>,
|
pub debounce_delay_millis: Option<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema)]
|
#[derive(Clone, Copy, Debug, Default, Deserialize, JsonSchema, PartialEq, Eq)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum GitGutterLevel {
|
pub enum GitFilesIncluded {
|
||||||
#[default]
|
#[default]
|
||||||
All,
|
All,
|
||||||
OnlyTracked,
|
OnlyTracked,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue