-
Notifications
You must be signed in to change notification settings - Fork 20
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
Breaking change introduced by adding private field to transparent Style
struct.
#46
Comments
Style
struct.
Dang, this just stinks. I really don't enjoy breaking everyone. Seems like we should figure out a way around this without breaking Style. |
I agree -- I was trying to avoid breaking Style in the first place (the alternate implementation broke it by dropping the Copy trait) but clearly did not succeed.
I think option 3 is the best and there might be a way to do it. I need to think about it some more though. Considering that there's already a commit that breaks external code that manually constructs Style { .. } I wonder if it might be wiser to immediately revert PR #43 for now to minimize pain and buy time so I can try for option 3. I could also add the test case you mentioned. |
@mhelsley @fdncred what speaks against making the field just Reconstruction is allowed and everyone using |
@alexkunde I could probably live with your suggestion. @sholderbach What do you think? |
@alexkunde As for motivation for not using I'm worried that exposing OSControl as part of the API might increase the likelihood of API users fiddling with it. That could introduce OSC sequences terminal emulators won't recognize or it might blow up the number of combinations nu-ansi-term will have to handle in the code in order to keep compatibility going forward. That's why my feeling is it would be preferable if there was some way to prevent code outside the crate from supplying anything except None in |
In my opinion, the enum OSControl is already a rather safe bet, since we have a pre-defined set of possibilities. The other way I would see is to create another lower level style object that is not exposed, with private values, and have the current In the end, it is @fdncred @sholderbach decision on how to proceed. |
I think I am at this point convinced we should go with Option 3 and avoid having those OSC code related behaviors in The beauty of having the transparent But the OSC code stuff doesn't really fit that bill in my view. The Hyperlinks (and the terminal/shell-intergration markers for prompt and output location to some extent) are slightly different in that they are still text being printed and "styled" but you only want to do those operations once for a particular In that sense the OSC operations should probably be methods and functions you can properly validate (potentially with |
@sholderbach @fdncred @alexkunde I put up a new RFC branch (add-osc-attempt2) in my fork showing what I think just the API changes would look like. For now it starts with reverting the original commit as a convenience to get this going quickly so folks can have a look. I can quickly turn it into option 3 but this might be easier to review for any design issues before I go further. It builds but is completely untested. I expect much of the test code will be very similar. I even modeled state tracking for semantic prompt functionality. Though I'm unsure that I recall the states and transitions correctly it still shows how it might be used to constrain callers to ensure they comply with valid state transitions while giving some idea of what more complex OSC codes might need. The idea is each creating a new instance in a subsequent state requires the instance with the previous state and starting with the "prompt" or None state. |
Move OSControl out of Style PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Also encloses the control sequences in \x01 .. \x02 to mark those portions which should be considered zero-width when displayed in the terminal. Fixes nushell#46
PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Also encloses the control sequences in \x01 .. \x02 to mark those portions which should be considered zero-width when displayed in the terminal. Closes nushell#46
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
I've written a test that manually constructs
I don't think I understand your For the OSC sequences, so far, I've just modified the original |
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
Yeah that should suffice for testing. I was thinking of extracting the fields through pattern matching in a
There is on some systems (a) file(s) that could through cryptic codes describe what a terminal can or cannot do and how it is set up at the moment. See
Awesome! Thanks |
Move OSControl out of Style PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Also encloses the control sequences in \x01 .. \x02 to mark those portions which should be considered zero-width when displayed in the terminal. Fixes nushell#46
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
Move OSControl out of Style PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Fixes nushell#46
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
Move OSControl out of Style PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Fixes nushell#46
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
Move OSControl out of Style PR nushell#43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Fixes nushell#46
PR nushell#43 introduced a pub(crate) field in Style which broke the intended API (See: Issue nushell#46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: nushell#46 (comment)
* Fix Style breakage Move OSControl out of Style PR #43 created a regression where code that manually instantiated a Style could no longer be created without using the update operator and Default trait on Style. Rather than place non-public functions and data in Style move it all into AnsiGenericString. This has the added benefit of greatly simplifying the code. Fixes #46 * testing: Add manual instance test for Style PR #43 introduced a pub(crate) field in Style which broke the intended API (See: Issue #46). Introduce a new test which will fail in those cases since it won't be able to initialize pub(crate) fields. Inspired by: #46 (comment) * Add examples of OSC usage * CI: Run OSC examples --------- Co-authored-by: Matt Helsley <[email protected]>
would it be possible to have a new release of nu-ansi-term with this change? |
@sylvestre we switched to a 4-week schedule to buy us more time between releases towards 1.0 😌 |
Sorry @amtoine, but what you are suggesting is simply unworkable as we use To your question @sylvestre, I will try to check a build of nushell (using |
Thanks @sholderbach. I agree. It's kind of a pain doing this. It looks to me like we'll need to release it so that |
Alright tested |
We could be more verbose like |
@sholderbach thanks, I appreciate it. This issue is preventing upgrades of the Rust/coreutils in Debian/Ubuntu :) |
See the test failure in https://github.com/sharkdp/lscolors/actions/runs/5187090829/jobs/9349029439
#43 added a
pub(crate)
field toStyle
which blocks outside consumers of the crate to manually constructStyle
.nu-ansi-term/src/style.rs
Lines 24 to 28 in 98b763f
Previously this was possible as all fields were marked
pub
and the types accessible to the outside world.Three possible courses of actions:
Style
shouldn't be built directly (and maybe hide all fields).OSControl
public if necessary.\Style
I currently favor the latter two options as with the many crates around ANSI styling in the ecosystem e.g. owo-colors etc. being able to transparently convert the base style as another crate is valuable.
As a lesson learned we should probably add a test that constructs and destructures
Style
manually. This would make a breakage to the API a bit more obvious. (Also worth looking into tools like https://crates.io/crates/cargo-semver-checks)The text was updated successfully, but these errors were encountered: