New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ls color problem on SubExpression #7689
Conversation
Working on exact detection to bypass this problem ... |
@rgwood Can you review this failed tests ? I throw |
that was a weird ci error. i restarted the failed job on the ci to see if they correct themselves. sometimes the ci just pukes. let's see if that's the case here. Update: Failed again.
Looking at the test, i'm not sure what 'row number too large' is supposed to mean. it seems odd that this #[test]
fn alias_recursion() -> TestResult {
run_test_contains(r#"alias ls = (ls | sort-by type name -i); ls"#, " ")
} This seems to work from the repl |
@fdncred |
Ok, glad you tracked it down. Am I understanding your code correctly? It appears that, on subexpressions, you're checking if the pipeline contains |
Yes .it's possible easily with some lines, but how can we detect |
I'm fine with the way it is if other core-team members sign off on it. I'm super grateful just to have ls_colors work in more places. |
Unfortunately, there are several problems with this approach. First, it does not work reliably. Auto-wrapping with Second, manually checking the pipeline for If I understand correctly, the problem is that the pipeline metadata gets lost during when the PipelineData becomes a Value. So, I think the solution would be to find a mechanism how to preserve the metadata during the transition. From the top of my head, I'm thinking of a hash map in the Stack storing the metadata with VarId as a key. I haven't looked into this problem in detail, though, I'm not sure if that would cover all the error cases. It probably needs a bit of design work to figure out a good solution. |
@kubouch |
I think now your current solution completely sidesteps the metadata from the pipeline. Now there are two overlapping systems for setting metadata from The key problem seems to be losing the metadata when evaluating a subexpression. So, we need a reliable way to store it and the only place to store it seems to me is the Stack (the caller stack, not the callee which gets dropped if I remember correctly). But it must be stored in such a way that correctly identifies the metadata with the pipeline that produced it. Maybe Span as the hash map key would work? But it might be too fragile, not sure. Another approach would be to return the metadata from |
Yeah, I tried it and you can generate a failure by doing
That's because the |
@kubouch |
I'm not sure I understand everything but having a new Value type that's Value+Metadata seems like it would add a lot of complexity and possible bugs anywhere you I'll bring it up to our core team to see what others think. |
Thanks . |
Semi-related I've been thinking about adding some type of Value to do date math better. In order to do date math better we would need to temporarily store the begin date time and end date time so that leap years, months, etc can be calculated correctly. Translating nanoseconds to durations isn't good enough for date math. I'm wondering if a separate value type is better for this or if we should have a value type that can carry more things like metadata. |
One Value which contains Currently watching Don't know where Core Developers will decide , but will appreciate if you apprise me about it or assign me for this , like to solve this problem . |
One problem with the Value + Metadata approach is that for every |
We don't need to use it everywhere , for ls if use it , we have to Match some commands related to ls like I think until we have these less commands and it is early , it's doable and necessary , because I think we will encounter new features which need a metadata . |
@kubouch Further PRs if our developers need a metadata can use it easily then in future features too . |
So we all agreed adding this new recursive
In both cases, we'd need to do some work before being able to address the metadata problem.
|
|
On first variant you mean create new Enum and cover |
Yeah, in the first case, adding a new The second option is about removing Span from being a part of Value and replacing it with an identifier pointing at a global storage of all Spans (similar to how definitions are handled in EngineState). This would reduce the size of the Value and consequently the whole Stack. The same identifier could be used to retrieve metadata as well. I think handling metadata this way is cleaner than adding a new Value enum variant. The two options are not mutually exclusive: The Value refactor would still be beneficial even if we use the second option for handling metadata. So yeah, we're putting the metadata on hold for now since there are issues to be handled before that and we need to discuss it a bit more. |
@kubouch |
I think we want to wait at this moment and first think of a good way forward. The issue is connected to other problems, as I described above, and we haven't yet decided how to proceed. |
I really wish we could move forward with this in some way. @Mehrbod2002 is motivated to work on it but the core-team hasn't really made a decision yet. I guess that's because this is "hard" to figure out. I'd like to find a way to move forward in the general right direction, even if we have to change it later. I'm just not sure what that is. |
@fdncred @kubouch |
@Mehrbod2002 I didn't look at the code much but I tried it and it didn't seem to work. |
@fdncred |
You are right @Mehrbod2002, it works. I have issues checking out your PR now. I get this unless I use
|
Yes |
I'm no git expert so this could be the wrong advice, but what i usually try to do is to make sure my main branch is up to date and then merge main on top of my changes. git checkout main |
@fdncred Problem with commit solved now ? |
yup, it works better now. |
This introduces the exact problem I described above. Adding a new enum variant adds too much developer overhead as we need to check every single pattern match on Value to see if it comes with Metadata. IMO this is too error-prone. |
Why do you think one condition is going to be too error-prone ? How many commands will use metadata now ? And this overhead is we use List and ValueWithMetadata on Ls which we will know it will be ValueWithMetadata . Anyway is there better way we can think on it appreciate to know it ( except change the whole core to cover Value with new enum ) |
I'm sad to see this closed. Hopefully we can come up with a work-able solution soon. Thanks @Mehrbod2002 for working so hard on this. |
Description
Fixes #7368 , #4319 , #4501 , or #7169
As
ls
called as value onlet
or parentheses()
, detectls
( added Expression after detectls
to not interrupt evaluating ) and evaluatetable
on it , it fixes missed metadata and attach `lscolor' PipeLineMetadata easily without conflict to core .