Skip to content
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

Truncating silently markup in RStudio when string ends with markup. #627

Closed
olivroy opened this issue Aug 30, 2023 · 6 comments
Closed

Truncating silently markup in RStudio when string ends with markup. #627

olivroy opened this issue Aug 30, 2023 · 6 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@olivroy
Copy link
Contributor

olivroy commented Aug 30, 2023

Edit: RStudio issue fixed in 2023.12.0 version

Possibly the string widths are not correctly assessed?,

Output of my RStudio console
image

Expected (works when cli.width >= 68.) i.e. if your console width is wider than 68 when not setting options.
image

because it seems to work as expected in the reprex

to_print <- "A long {.val value} with a {.href [link](https://github.com)} with other stuff like {.help cli::inline-markup}"
options(cli.width = 35)
cli::cli_bullets(to_print)
#> A long "value" with a link
#> (<https://github.com>) with other
#> stuff like `?cli::inline-markup()`

Created on 2023-08-30 with reprex v2.0.2

Related to #578, because I first encountered this behaviour at startup, but this seems like a different issue.

Note: I used options(cli.width) here for reproducibility purpose only, but I am trying to recreate the behavior when not setting options.

Let me know if I can provide more info. (I am still on an older RStudio version 2023.06.1, but I don't think this has been changed recently.)

  • This seems related to console width, because when the console is wide enough, this doesn't seem to occur.
@gaborcsardi gaborcsardi added the bug an unexpected problem or unintended behavior label Aug 30, 2023
@olivroy olivroy changed the title Truncating silently markup in RStudio Truncating silently markup in RStudio when string ends with markup. Aug 30, 2023
@olivroy
Copy link
Contributor Author

olivroy commented Aug 30, 2023

Oh! I just discovered something else: the bug occurs in some situations, but having inline markup at the end of the string seems to be more problematic.

# This works as expected
to_print <- "A long {.val value} with a {.href [link](https://github.com)} with other stuff like {.help cli::inline-markup} is okay."

Once the end of string inline markup bug is fixed, I can see if silent truncation comes up in other situations.

I can circumvent this by setting options(cli.width = Inf), but this is not ideal as it can other have undesired effects.

@olivroy olivroy closed this as completed Aug 30, 2023
@olivroy olivroy reopened this Aug 30, 2023
@olivroy
Copy link
Contributor Author

olivroy commented Sep 13, 2023

@gaborcsardi I tried creating a failing test for that, but could not see what was wrong. I am only able to reproduce in RStudio interactively.

I tried the following. but the snapshot looks fine, but does not reflect the interactive behavior.

  expect_snapshot({
    withr::local_envvar(
      R_CLI_HYPERLINKS = "true",
      R_CLI_HYPERLINK_RUN = "true"
    )
    rlang::local_interactive()
    withr::local_options(cli.unicode = TRUE)
    withr::local_options(cli.num.color = 256L)
    withr::local_options(cli.width = 25)
    cli_text("A {.val veryaaaaa} long hyperlink {.href [text](https://github.com)}")
  }

  )

Edit: this problem has more impact than I thought also. It seemed to interfere in a styler warning that I saw yesterday. maybe related to #562?

@olivroy
Copy link
Contributor Author

olivroy commented Nov 2, 2023

Hi @gaborcsardi, do you think this is a cli or RStudio issue? Do you think it will be fixed by rstudio/rstudio#13869. If so, maybe mention it for QA.

@gaborcsardi
Copy link
Member

Does it happen outside of RStudio? E.g. in a (non-RStudio) terminal?

@olivroy
Copy link
Contributor Author

olivroy commented Nov 2, 2023

Doesn't seem like it. (although I don't have a terminal that supports links)

Are you able to see this behavior with this reprex in a terminal? (the word value doesn't appear)

to_print <- "A long {.val value} with a {.href [link](https://github.com)} with other stuff like {.help cli::inline-markup}"
options(cli.width = 35)
cli::cli_bullets(to_print)

@gaborcsardi
Copy link
Member

gaborcsardi commented Nov 2, 2023

It works in a terminal. It is probably this issue: #560, already reported to RStudio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants