mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-26 03:07:18 +02:00
Fix description width when using truncated_count
This commit is contained in:
parent
a30dd2f86f
commit
13e0cf3d16
2 changed files with 11 additions and 2 deletions
|
@ -612,6 +612,13 @@ impl TTApp {
|
||||||
let maximum_column_width = rect.width;
|
let maximum_column_width = rect.width;
|
||||||
let widths = self.calculate_widths(&tasks, &headers, maximum_column_width);
|
let widths = self.calculate_widths(&tasks, &headers, maximum_column_width);
|
||||||
|
|
||||||
|
for (i, header) in headers.iter().enumerate() {
|
||||||
|
if header == "Description" || header == "Definition" {
|
||||||
|
self.task_report_table.description_width = widths[i] - 3*headers.iter().len();
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let selected = self.task_table_state.selected().unwrap_or_default();
|
let selected = self.task_table_state.selected().unwrap_or_default();
|
||||||
let header = headers.iter();
|
let header = headers.iter();
|
||||||
let mut rows = vec![];
|
let mut rows = vec![];
|
||||||
|
|
|
@ -37,6 +37,7 @@ pub struct TaskReportTable {
|
||||||
pub columns: Vec<String>,
|
pub columns: Vec<String>,
|
||||||
pub tasks: Vec<Vec<String>>,
|
pub tasks: Vec<Vec<String>>,
|
||||||
pub virtual_tags: Vec<String>,
|
pub virtual_tags: Vec<String>,
|
||||||
|
pub description_width: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TaskReportTable {
|
impl TaskReportTable {
|
||||||
|
@ -79,6 +80,7 @@ impl TaskReportTable {
|
||||||
columns: vec![],
|
columns: vec![],
|
||||||
tasks: vec![vec![]],
|
tasks: vec![vec![]],
|
||||||
virtual_tags: virtual_tags.iter().map(|s| s.to_string()).collect::<Vec<_>>(),
|
virtual_tags: virtual_tags.iter().map(|s| s.to_string()).collect::<Vec<_>>(),
|
||||||
|
description_width: 100,
|
||||||
};
|
};
|
||||||
task_report_table.export_headers()?;
|
task_report_table.export_headers()?;
|
||||||
Ok(task_report_table)
|
Ok(task_report_table)
|
||||||
|
@ -234,7 +236,7 @@ impl TaskReportTable {
|
||||||
None => format!(""),
|
None => format!(""),
|
||||||
};
|
};
|
||||||
let mut d = task.description().to_string();
|
let mut d = task.description().to_string();
|
||||||
let mut end = 20;
|
let mut end = self.description_width;
|
||||||
while !d.is_char_boundary(end) && end < d.len() {
|
while !d.is_char_boundary(end) && end < d.len() {
|
||||||
end += 1;
|
end += 1;
|
||||||
}
|
}
|
||||||
|
@ -246,7 +248,7 @@ impl TaskReportTable {
|
||||||
},
|
},
|
||||||
"description.truncated" => {
|
"description.truncated" => {
|
||||||
let mut d = task.description().to_string();
|
let mut d = task.description().to_string();
|
||||||
let mut end = 20;
|
let mut end = self.description_width;
|
||||||
while !d.is_char_boundary(end) && end < d.len() {
|
while !d.is_char_boundary(end) && end < d.len() {
|
||||||
end += 1;
|
end += 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue