File tree 3 files changed +17
-4
lines changed
3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ impl Config {
128
128
self . yaml . style . comment . width_percentage
129
129
}
130
130
131
+ pub fn snippet_width_percentage ( & self ) -> u16 {
132
+ self . yaml . style . snippet . width_percentage
133
+ }
134
+
131
135
pub fn tag_min_width ( & self ) -> u16 {
132
136
self . yaml . style . tag . min_width
133
137
}
@@ -136,6 +140,10 @@ impl Config {
136
140
self . yaml . style . comment . min_width
137
141
}
138
142
143
+ pub fn snippet_min_width ( & self ) -> u16 {
144
+ self . yaml . style . snippet . min_width
145
+ }
146
+
139
147
#[ cfg( feature = "disable-command-execution" ) ]
140
148
fn print ( & self ) -> bool {
141
149
true
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use crate::terminal;
3
3
pub use crate :: terminal:: style:: style;
4
4
use std:: cmp:: max;
5
5
6
- pub fn get_widths ( ) -> ( usize , usize ) {
6
+ pub fn get_widths ( ) -> ( usize , usize , usize ) {
7
7
let width = terminal:: width ( ) ;
8
8
let tag_width_percentage = max (
9
9
CONFIG . tag_min_width ( ) ,
@@ -13,8 +13,13 @@ pub fn get_widths() -> (usize, usize) {
13
13
CONFIG . comment_min_width ( ) ,
14
14
width * CONFIG . comment_width_percentage ( ) / 100 ,
15
15
) ;
16
+ let snippet_width_percentage = max (
17
+ CONFIG . snippet_min_width ( ) ,
18
+ width * CONFIG . snippet_width_percentage ( ) / 100 ,
19
+ ) ;
16
20
(
17
21
usize:: from ( tag_width_percentage) ,
18
22
usize:: from ( comment_width_percentage) ,
23
+ usize:: from ( snippet_width_percentage) ,
19
24
)
20
25
}
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ pub const DELIMITER: &str = r" ⠀";
11
11
lazy_static ! {
12
12
pub static ref NEWLINE_REGEX : Regex = Regex :: new( r"\\\s+" ) . expect( "Invalid regex" ) ;
13
13
pub static ref VAR_REGEX : Regex = Regex :: new( r"\\?<(\w[\w\d\-_]*)>" ) . expect( "Invalid regex" ) ;
14
- pub static ref COLUMN_WIDTHS : ( usize , usize ) = ui:: get_widths( ) ;
14
+ pub static ref COLUMN_WIDTHS : ( usize , usize , usize ) = ui:: get_widths( ) ;
15
15
}
16
16
17
17
pub fn with_new_lines ( txt : String ) -> String {
@@ -37,12 +37,12 @@ fn limit_str(text: &str, length: usize) -> String {
37
37
}
38
38
39
39
pub fn write ( item : & Item ) -> String {
40
- let ( tag_width_percentage, comment_width_percentage) = * COLUMN_WIDTHS ;
40
+ let ( tag_width_percentage, comment_width_percentage, snippet_width_percentage ) = * COLUMN_WIDTHS ;
41
41
format ! (
42
42
"{tags_short}{delimiter}{comment_short}{delimiter}{snippet_short}{delimiter}{tags}{delimiter}{comment}{delimiter}{snippet}{delimiter}{file_index}{delimiter}\n " ,
43
43
tags_short = ui:: style( limit_str( & item. tags, tag_width_percentage) ) . with( CONFIG . tag_color( ) ) ,
44
44
comment_short = ui:: style( limit_str( & item. comment, comment_width_percentage) ) . with( CONFIG . comment_color( ) ) ,
45
- snippet_short = ui:: style( fix_newlines( & item. snippet) ) . with( CONFIG . snippet_color( ) ) ,
45
+ snippet_short = ui:: style( limit_str ( & fix_newlines( & item. snippet) , snippet_width_percentage ) ) . with( CONFIG . snippet_color( ) ) ,
46
46
tags = item. tags,
47
47
comment = item. comment,
48
48
delimiter = DELIMITER ,
You can’t perform that action at this time.
0 commit comments