Repository: denisidoro/navi
File: src/finder/mod.rs (Rust)

Code before:
            _ => 2,
        };

        let bindings = if opts.suggestion_type == SuggestionType::MultipleSelections {
            ",ctrl-r:toggle-all"
        } else {
            ""
        };

        command.args([
            "--preview",
            "",
            "--preview-window",
            format!("up:{preview_height}:nohidden").as_str(),
            "--delimiter",
            deser::terminal::DELIMITER.to_string().as_str(),
            "--ansi",
            "--bind",
            format!("ctrl-j:down,ctrl-k:up{bindings}").as_str(),
            "--exact",
            "--read0",
            "--print0",
        ]);

        if !opts.show_all_columns {
            command.args(["--with-nth", "1"]);
        }

        if !opts.prevent_select1 {
            if let Self::Fzf = self {
                command.arg("--select-1");
            }
        }

        match opts.suggestion_type {
            SuggestionType::MultipleSelections => {
                command.arg("--multi");
            }
            SuggestionType::Disabled => {
                if let Self::Fzf = self {
                    command.args(["--print-query", "--no-select-1"]);
                };
            }
            SuggestionType::SnippetSelection => {
                command.args(["--expect", "ctrl-y,ctrl-o,enter"]);
            }
            SuggestionType::SingleRecommendation => {
                command.args(["--print-query", "--expect", "tab,enter"]);
            }
            _ => {}
        }

Review comment (bug):
`show_all_columns` seems to be true only when selecting values.
So adding `--read0` and `--print0` in this block fixes the bug related to selecting values.
But it would be better to introduce another option or rename the option.

Code after:
            _ => 2,
        };

        let bindings = if opts.suggestion_type == SuggestionType::MultipleSelections {
            ",ctrl-r:toggle-all"
        } else {
            ""
        };

        command.args([
            "--preview",
            "",
            "--preview-window",
            format!("up:{preview_height}:nohidden").as_str(),
            "--delimiter",
            deser::terminal::DELIMITER.to_string().as_str(),
            "--ansi",
            "--bind",
            format!("ctrl-j:down,ctrl-k:up{bindings}").as_str(),
            "--exact",
        ]);

        if !opts.show_all_columns {
            let with_nth = if CONFIG.multiline() { "1" } else { "1,2,3" };
            command.args(["--read0", "--print0", "--with-nth", with_nth]);
        }

        if !opts.prevent_select1 {
            if let Self::Fzf = self {
                command.arg("--select-1");
            }
        }

        match opts.suggestion_type {
            SuggestionType::MultipleSelections => {
                command.arg("--multi");
            }
            SuggestionType::Disabled => {
                if let Self::Fzf = self {
                    command.args(["--print-query", "--no-select-1"]);
                };
            }
            SuggestionType::SnippetSelection => {
                command.args(["--expect", "ctrl-y,ctrl-o,enter"]);
            }
            SuggestionType::SingleRecommendation => {
                command.args(["--print-query", "--expect", "tab,enter"]);
            }
            _ => {}
        }