preserve the case of the original string in the output.

This commit is contained in:
Ben Yang 2024-06-27 16:27:36 +08:00
parent 46ed69ab12
commit ab93d89e33

View File

@ -1,5 +1,6 @@
use crate::help::highlight_search_string;
use fancy_regex::Regex;
use log::info;
use nu_ansi_term::Style;
use nu_color_config::StyleComputer;
use nu_engine::command_prelude::*;
@ -450,6 +451,7 @@ fn find_with_rest_and_highlight(
PipelineData::ByteStream(stream, ..) => {
let span = stream.span();
if let Some(lines) = stream.lines() {
let terms = lower_terms
.into_iter()
.map(|term| term.to_expanded_string("", &filter_config).to_lowercase())
@ -457,9 +459,10 @@ fn find_with_rest_and_highlight(
let mut output: Vec<Value> = vec![];
for line in lines {
let line = line?.to_lowercase();
let line = line?;
let lower_val = line.to_lowercase();
for term in &terms {
if line.contains(term) {
if lower_val.contains(term) {
output.push(Value::string(
highlight_search_string(
&line,