Skip to content

Commit

Permalink
fix: test
Browse files Browse the repository at this point in the history
  • Loading branch information
Thaumy committed Sep 19, 2023
1 parent e4458d5 commit e332ef2
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
12 changes: 1 addition & 11 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ futures = "0.3.28"

clap = { version = "4.4.3", features = ["derive", "wrap_help"] }
colored = "2.0.4"
term_size = "0.3.2"
terminal_size = "0.2.6"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
3 changes: 2 additions & 1 deletion src/display/colorful.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use colored::Colorize;
use std::fmt::Display;
use std::ops::Not;
use std::path::PathBuf;
use terminal_size::terminal_size;
use unicode_width::UnicodeWidthStr;

pub fn login(cfg_path: &Result<PathBuf>) {
Expand Down Expand Up @@ -90,7 +91,7 @@ pub fn list_ing(
println!(" {} {}", "#".dimmed(), ing.id.to_string().dimmed());
let content = if align {
let user_name_width = ing.user_name.width_cjk();
let (term_width, _) = term_size::dimensions().expect("Can not get terminal size");
let term_width = terminal_size().expect("Can not get terminal size").0 .0 as usize;
let left_width = term_width.saturating_sub(user_name_width + 3);
fmt_content(&ing.content)
.width_split(left_width)
Expand Down
3 changes: 2 additions & 1 deletion src/display/normal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use colored::Colorize;
use std::fmt::Display;
use std::ops::Not;
use std::path::PathBuf;
use terminal_size::terminal_size;
use unicode_width::UnicodeWidthStr;

pub fn login(cfg_path: &Result<PathBuf>) {
Expand Down Expand Up @@ -90,7 +91,7 @@ pub fn list_ing(
println!(" # {}", ing.id);
let content = if align {
let user_name_width = ing.user_name.width_cjk();
let (term_width, _) = term_size::dimensions().expect("Can not get terminal size");
let term_width = terminal_size().expect("Can not get terminal size").0 .0 as usize;
let left_width = term_width.saturating_sub(user_name_width + 3);
fmt_content(&ing.content)
.width_split(left_width)
Expand Down
1 change: 1 addition & 0 deletions src/infra/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn test_width_split_head() {

#[test]
fn test_width_split() {
use crate::infra::option::IntoOption;
let text = "测试test⭐测试test⭐";
assert_eq!(text.width_split(0), None);
assert_eq!(text.width_split(1), None);
Expand Down

0 comments on commit e332ef2

Please sign in to comment.