Repository navigation
fix: highlighting a where command with invalid arguments can duplicate text - #16192
Merged
Merged
Conversation
Parsing a multi span value as RowCondition always produces a RowCondition expression that covers all the spans. Which is problematic inside OneOf and can produce multiple expressions with overlapping spans. Short circuiting on RowCondition while parsing OneOf prevents this. Fixes nushell#16129
blindFS
reviewed
Jul 17, 2025
This reverts commit f5baaa7.
Only reason for including SyntaxShape::Closure in the signature was to make it clear in help texts that closures can be used as the argument. Simplifying the signature simplifies the parsing, so using a RowCondition on its own and instead making it always look like a union with `closure(any)` solves the issue without any changes in the parser. Also, RowCondition will always accept closures anyway, so its textual representation should always indicate that without the need for OneOf.
132ikl
approved these changes
Jul 22, 2025
hardfau1t
pushed a commit
to hardfau1t/nushell
that referenced
this pull request
Aug 25, 2025
…e text (nushell#16192) - fixes nushell#16129 # Description ## Problem Parsing a multi span value as RowCondition always produces a RowCondition expression that covers all the spans. Which is problematic inside OneOf and can produce multiple expressions with overlapping spans. Which results in funky highlighting that duplicates text. ## Solution Only reason for including `SyntaxShape::Closure` in the signature (nushell#15697) was for documentation purposes, making it clear in `help` texts that a closure can be used as the argument. As our current parser is shape directed, simplifying the command signature means simplifies the parsing, so using a RowCondition on its own, and instead making it always look like a union with `closure(any)` solves the issue without any changes in the parser. Also, RowCondition always accepts closure values anyway, so its textual representation should indicate that without the need to wrap it in OneOf. Co-authored-by: Bahex <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
wherecommand #16129Description
Problem
Parsing a multi span value as RowCondition always produces a RowCondition
expression that covers all the spans.
Which is problematic inside OneOf and can produce multiple expressions with overlapping spans.

Which results in funky highlighting that duplicates text:
Solution
Short circuiting on RowCondition while parsing OneOf (OneOf expression that contains RowCondition will always be parsed as RowCondition), prevents that.Only reason for including
SyntaxShape::Closurein the signature (#15697) was for documentation purposes, making it clearhelptexts that a closure can be used as the argument.As our current parser is shape directed, simplifying the command signature means simplifies the parsing, so using a RowCondition on its own, and instead making it always look like a union with
closure(any)solves the issue without any changes in the parser.Also, RowCondition always accepts closure values anyway, so its textual representation should indicate that without the need to wrap it in OneOf.
Tests + Formatting
+1 test to catch it if it ever reoccurs