Skip to content
Open
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
5 changes: 5 additions & 0 deletions .codegraph-wsl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CodeGraph data files — local to each machine, not for committing.
# Ignore everything in .codegraph/ except this file itself, so transient
# files (the database, daemon.pid, sockets, logs) never show up in git.
*
!.gitignore
16 changes: 11 additions & 5 deletions crates/rgitui_diff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rgitui_git::{
ConflictSnapshot, DiffLine, FileDiff, MergeSection, ThreeWayFileDiff, WorktreePatchDirection,
WorktreePatchScope, WorktreePatchSource,
};
use rgitui_settings::{SettingsState, TrKey};
use rgitui_theme::{ActiveTheme, Appearance, Color, StyledExt, ThemeState};
use rgitui_ui::{
Badge, Button, ButtonSize, ButtonStyle, EstimatedListScroll, Icon, IconName, IconSize, Label,
Expand Down Expand Up @@ -885,6 +886,9 @@ impl DiffViewer {
this.rehighlight(cx);
})
.detach();
// Re-render immediately when the interface language changes.
cx.observe_global::<SettingsState>(|_, cx| cx.notify())
.detach();

Self {
diff: None,
Expand Down Expand Up @@ -3412,11 +3416,12 @@ impl DiffViewer {
if self.file_menu_operations().is_empty() {
return div().into_any_element();
}
let language = cx.global::<SettingsState>().settings().language;
let tooltip: SharedString = match self.source.revision_label() {
Some(revision) => format!("Apply or revert this whole file from {revision}").into(),
None => "Whole-file operations".into(),
};
Button::new("diff-file-menu", "File")
Button::new("diff-file-menu", language.tr(TrKey::DiffFileBtn))
.size(ButtonSize::Compact)
.style(ButtonStyle::Subtle)
.tooltip(tooltip)
Expand Down Expand Up @@ -3549,6 +3554,7 @@ impl Render for DiffViewer {
self.sbs_rows.len()
);
let colors = cx.colors();
let language = cx.global::<SettingsState>().settings().language;

let has_content = self.diff.is_some() || self.three_way_diff.is_some();
if self.error.is_some() || self.loading || !has_content {
Expand Down Expand Up @@ -3610,7 +3616,7 @@ impl Render for DiffViewer {
)
.when(is_conflict, |element| {
element.child(
Button::new("conflict-error-open", "Open File")
Button::new("conflict-error-open", language.tr(TrKey::DiffOpenFile))
.size(ButtonSize::Compact)
.style(ButtonStyle::Outlined)
.on_click(cx.listener(|this, _: &ClickEvent, _, cx| {
Expand All @@ -3631,12 +3637,12 @@ impl Render for DiffViewer {
.color(Color::Placeholder),
)
.child(
Label::new("Select a file to view changes")
Label::new(language.tr(TrKey::DiffEmptyTitle))
.size(LabelSize::Small)
.color(Color::Muted),
)
.child(
Label::new("Click a file in the sidebar or detail panel")
Label::new(language.tr(TrKey::DiffEmptyDesc))
.size(LabelSize::XSmall)
.color(Color::Placeholder),
)
Expand Down Expand Up @@ -5207,7 +5213,7 @@ impl Render for DiffViewer {
)),
)
.child(
Button::new("conflict-open-editor", "Open File")
Button::new("conflict-open-editor", language.tr(TrKey::DiffOpenFile))
.size(ButtonSize::Compact)
.style(ButtonStyle::Subtle)
.tooltip("Open the working file in your configured editor")
Expand Down
18 changes: 10 additions & 8 deletions crates/rgitui_git/src/project/diff.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use anyhow::Result;
use git2::{DiffOptions, IndexEntry, MergeFileOptions, Repository};
use rgitui_settings::TrKey;
use std::path::{Path, PathBuf};

use crate::types::*;

use super::op_i18n::{op_err_text, op_msg};
use super::refresh::gather_refresh_data_lightweight_cached;
use super::RefreshData;

Expand Down Expand Up @@ -780,8 +782,8 @@ impl GitProject {
this.fail_op(
operation_id,
GitOperationKind::Stage,
"Stage hunk failed",
e.to_string(),
op_msg(cx, TrKey::ErrStageHunkFailed, vec![]),
op_err_text(cx, &e),
(None, branch_name.clone(), false),
cx,
);
Expand Down Expand Up @@ -863,8 +865,8 @@ impl GitProject {
this.fail_op(
operation_id,
GitOperationKind::Unstage,
"Unstage hunk failed",
e.to_string(),
op_msg(cx, TrKey::ErrUnstageHunkFailed, vec![]),
op_err_text(cx, &e),
(None, branch_name.clone(), false),
cx,
);
Expand Down Expand Up @@ -953,8 +955,8 @@ impl GitProject {
this.fail_op(
operation_id,
GitOperationKind::Stage,
"Stage lines failed",
e.to_string(),
op_msg(cx, TrKey::ErrStageLinesFailed, vec![]),
op_err_text(cx, &e),
(None, branch_name.clone(), false),
cx,
);
Expand Down Expand Up @@ -1045,8 +1047,8 @@ impl GitProject {
this.fail_op(
operation_id,
GitOperationKind::Unstage,
"Unstage lines failed",
e.to_string(),
op_msg(cx, TrKey::ErrUnstageLinesFailed, vec![]),
op_err_text(cx, &e),
(None, branch_name.clone(), false),
cx,
);
Expand Down
Loading