Skip to content

Duplicated text in the command line after where command #16129

Closed

Description

@simonborje

Describe the bug

When arguments after the where command are marked as invalid, such arguments containing characters followed by a ( have the part before the ( duplicated. If the ( is removed, or the argument becomes valid, the duplicated character disappear.

Image

How to reproduce

  1. Type ls | where a b 12345
  2. Add ( at the end of the last argument, making it 12345(
  3. The command line will show ls | where a b 1234512345(

Expected behavior

No text duplication.

Configuration

key value
version 0.105.1
major 0
minor 105
patch 1
branch
commit_hash 1fe62ee
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.85.1 (4eb161250 2025-03-15)
rust_channel 1.85.1-x86_64-pc-windows-msvc
cargo_version cargo 1.85.1 (d73d2caf9 2024-12-31)
build_time 2025-06-10 19:56:11 +00:00
build_rust_channel release
allocator standard
features default, sqlite, trash
installed_plugins

Windows 11 using Windows terminal with default settings.

Activity

  1. added
    status:needs-triage
    on Jul 8, 2025
  2. blindFS commented on Jul 8, 2025

    @blindFS
    Contributor

    Really weird, it only occurs on arguments at odd-numbered positions starting from 3.

  3. added
    A:syntax-highlighting
    category:bug
    on Jul 8, 2025
  4. self-assigned this
    on Jul 8, 2025
  5. 132ikl commented on Jul 9, 2025

    @132ikl
    Member

    this is duplicate of #15899, but this one is more discoverable so I'll close the other one

    important info from that issue is that I bisected this to #15697, and this is specifically an issue with nu-highlight

  6. blindFS commented on Jul 9, 2025

    @blindFS
    Contributor

    Probably has something to do with the best_guess of parse_oneof:

    fn parse_oneof(
    working_set: &mut StateWorkingSet,
    spans: &[Span],
    spans_idx: &mut usize,
    possible_shapes: &Vec<SyntaxShape>,
    multispan: bool,
    ) -> Expression {
    let starting_spans_idx = *spans_idx;
    let mut best_guess = None;
    let mut best_guess_errors = Vec::new();
    let mut max_first_error_offset = 0;
    let mut propagate_error = false;
    for shape in possible_shapes {
    let starting_error_count = working_set.parse_errors.len();
    *spans_idx = starting_spans_idx;
    let value = match multispan {
    true => parse_multispan_value(working_set, spans, spans_idx, shape),
    false => parse_value(working_set, spans[*spans_idx], shape),
    };
    let new_errors = working_set.parse_errors[starting_error_count..].to_vec();
    // no new errors found means success
    let Some(first_error_offset) = new_errors.iter().map(|e| e.span().start).min() else {
    return value;
    };
    if first_error_offset > max_first_error_offset {
    // while trying the possible shapes, ignore Expected type errors
    // unless they're inside a block, closure, or expression
    propagate_error = match working_set.parse_errors.last() {
    Some(ParseError::Expected(_, error_span))
    | Some(ParseError::ExpectedWithStringMsg(_, error_span)) => {
    matches!(
    shape,
    SyntaxShape::Block | SyntaxShape::Closure(_) | SyntaxShape::Expression
    ) && *error_span != spans[*spans_idx]
    }
    _ => true,
    };
    max_first_error_offset = first_error_offset;
    best_guess = Some(value);
    best_guess_errors = new_errors;
    }
    working_set.parse_errors.truncate(starting_error_count);
    }
    // if best_guess results in new errors further than current span, then accept it
    // or propagate_error is marked as true for it
    if max_first_error_offset > spans[starting_spans_idx].start || propagate_error {
    working_set.parse_errors.extend(best_guess_errors);
    best_guess.expect("best_guess should not be None here!")
    } else {
    working_set.error(ParseError::ExpectedWithStringMsg(
    format!("one of a list of accepted shapes: {possible_shapes:?}"),
    spans[starting_spans_idx],
    ));
    Expression::garbage(working_set, spans[starting_spans_idx])
    }
    }

  7. added a commit that references this issue on Jul 16, 2025
    f5baaa7
  8. added a commit that references this issue on Jul 22, 2025
    51265b2
  9. added this to the v0.106.0 milestone on Jul 22, 2025
  10. added a commit that references this issue on Aug 25, 2025
    f202396
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A:syntax-highlightingcategory:bugstatus:needs-triage

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions