-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
diff: specify available terminal width by caller, subtract graph width
The width parameter is mandatory so it wouldn't fall back to ui.term_width() by mistake. The API is getting messy and we might want to extract some parameters to separate struct. Fixes #4158
- Loading branch information
Showing
9 changed files
with
106 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,7 @@ pub(crate) fn cmd_interdiff( | |
&from_tree, | ||
&to_tree, | ||
matcher.as_ref(), | ||
ui.term_width(), | ||
)?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1377,6 +1377,53 @@ fn test_log_word_wrap() { | |
"###); | ||
} | ||
|
||
#[test] | ||
fn test_log_diff_stat_width() { | ||
let test_env = TestEnvironment::default(); | ||
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]); | ||
let repo_path = test_env.env_root().join("repo"); | ||
let render = |args: &[&str], columns: u32| { | ||
let assert = test_env | ||
.jj_cmd(&repo_path, args) | ||
.env("COLUMNS", columns.to_string()) | ||
.assert() | ||
.success() | ||
.stderr(""); | ||
get_stdout_string(&assert) | ||
}; | ||
|
||
std::fs::write(repo_path.join("file1"), "foo\n".repeat(100)).unwrap(); | ||
test_env.jj_cmd_ok(&repo_path, &["new", "root()"]); | ||
std::fs::write(repo_path.join("file2"), "foo\n".repeat(100)).unwrap(); | ||
|
||
insta::assert_snapshot!(render(&["log", "--stat", "--no-graph"], 30), @r###" | ||
rlvkpnrz [email protected] 2001-02-03 08:05:09 287520bf | ||
(no description set) | ||
file2 | 100 +++++++++++++++ | ||
1 file changed, 100 insertions(+), 0 deletions(-) | ||
qpvuntsm [email protected] 2001-02-03 08:05:08 e292def1 | ||
(no description set) | ||
file1 | 100 +++++++++++++++ | ||
1 file changed, 100 insertions(+), 0 deletions(-) | ||
zzzzzzzz root() 00000000 | ||
0 files changed, 0 insertions(+), 0 deletions(-) | ||
"###); | ||
|
||
// Graph width should be subtracted | ||
insta::assert_snapshot!(render(&["log", "--stat"], 30), @r###" | ||
@ rlvkpnrz [email protected] 2001-02-03 08:05:09 287520bf | ||
│ (no description set) | ||
│ file2 | 100 ++++++++++++ | ||
│ 1 file changed, 100 insertions(+), 0 deletions(-) | ||
│ ○ qpvuntsm [email protected] 2001-02-03 08:05:08 e292def1 | ||
├─╯ (no description set) | ||
│ file1 | 100 ++++++++++ | ||
│ 1 file changed, 100 insertions(+), 0 deletions(-) | ||
◆ zzzzzzzz root() 00000000 | ||
0 files changed, 0 insertions(+), 0 deletions(-) | ||
"###); | ||
} | ||
|
||
#[test] | ||
fn test_elided() { | ||
// Test that elided commits are shown as synthetic nodes. | ||
|