Fix file git status refresh on .gitignore update (#9466)

This PR fixes file name coloring in the project panel and tabs when
.gitignore file is updated. It's intended to fix #7831.

There's another, less vivid, problem with git-aware labels coloring.
It's about files that are both ignored and contained in the git index.
I'll file a separate issue for it to keep this fix focused.

Release Notes:

- Fixed file Git status refreshing on .gitignore update (#7831).
This commit is contained in:
Andrew Lygin 2024-03-19 05:35:38 +03:00 committed by GitHub
parent 1e1fb21c81
commit 192cd5f2d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 132 additions and 65 deletions

View file

@ -4,7 +4,7 @@ use client::{ErrorCode, ErrorExt};
use settings::Settings;
use db::kvp::KEY_VALUE_STORE;
use editor::{actions::Cancel, scroll::Autoscroll, Editor};
use editor::{actions::Cancel, items::entry_git_aware_label_color, scroll::Autoscroll, Editor};
use file_associations::FileAssociations;
use anyhow::{anyhow, Result};
@ -1180,7 +1180,7 @@ impl ProjectPanel {
inode: 0,
mtime: entry.mtime,
is_symlink: false,
is_ignored: false,
is_ignored: entry.is_ignored,
is_external: false,
is_private: false,
git_status: entry.git_status,
@ -1408,23 +1408,8 @@ impl ProjectPanel {
.selection
.map_or(false, |selection| selection.entry_id == entry_id);
let width = self.size(cx);
let filename_text_color = details
.git_status
.as_ref()
.map(|status| match status {
GitFileStatus::Added => Color::Created,
GitFileStatus::Modified => Color::Modified,
GitFileStatus::Conflict => Color::Conflict,
})
.unwrap_or(if is_selected {
Color::Default
} else if details.is_ignored {
Color::Disabled
} else {
Color::Muted
});
let filename_text_color =
entry_git_aware_label_color(details.git_status, details.is_ignored, is_selected);
let file_name = details.filename.clone();
let icon = details.icon.clone();
let depth = details.depth;