diff --git a/rust/skim/src/lib.rs b/rust/skim/src/lib.rs index 00ee6c8c9c2..2221ed63df4 100644 --- a/rust/skim/src/lib.rs +++ b/rust/skim/src/lib.rs @@ -10,22 +10,25 @@ mod ffi { } struct Item { - text: String, + text_no_newlines: String, orig_text: String, } impl Item { fn new(text: String) -> Self { return Self{ + // Text that will be printed by skim, and will be used for matching. + // // Text that will be shown should not contains new lines since in this case skim may // live some symbols on the screen, and this looks odd. - text: text.replace("\n", " "), + text_no_newlines: text.replace("\n", " "), + // This will be used when the match had been selected. orig_text: text, }; } } impl SkimItem for Item { fn text(&self) -> Cow { - return Cow::Borrowed(&self.text); + return Cow::Borrowed(&self.text_no_newlines); } fn output(&self) -> Cow { @@ -44,6 +47,24 @@ fn skim(prefix: &CxxString, words: &CxxVector) -> Result