Skip to content

Conversation

@gadenbuie
Copy link
Collaborator

Fixes a small bug in print.ellmer_prompt() to correctly truncate lines and items independently.

I noticed this by using ellmer::interpolate_file() to read in a prompt with >200 lines.

Before

ellmer::interpolate(paste(letters, collapse = "\n")) |> 
  print(max_lines = 3)
#> [1] │ a
#>     │ b
#>     │ c
#>     │ ...
#> Error in if (n_extra > 0) {: missing value where TRUE/FALSE needed

After

ellmer::interpolate(paste(letters, collapse = "\n")) |> 
  print(max_lines = 3)
#> [1] │ a
#>     │ b
#>     │ c
#>     │ ...and 23 more lines.

@hadley
Copy link
Member

hadley commented Oct 7, 2025

I just fixed this in testthat too: r-lib/testthat#2257. You might want to take that instead since it looks a little simpler.

This is why you shouldn't copy and paste code kids.

@gadenbuie gadenbuie requested review from hadley and removed request for hadley October 7, 2025 21:34
@gadenbuie gadenbuie merged commit 1ab282c into main Oct 9, 2025
11 checks passed
@gadenbuie gadenbuie deleted the fix/ellmer-prompt-truncate branch October 9, 2025 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants