rstudio / rstudio/bslib

input_code_editor(): caret is still off-set

Open
#1,332 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triage:done duplicate Priority: Medium
Dominant language
SCSS
Stars
569
Forks
72
Avg merge
1d 2h
Merged PRs (30d)
5

Description

Describe the problem

Same issue as #1303, the reprex is still valid:

library(shiny)
library(bslib)

ui <- page_fillable(
   layout_columns(
      card(
         card_header("Code Editor"),
         input_code_editor(
            "code",
            label = "Enter R code:",
            value = "f <- function(x) x + 1\nf(42)",
            language = "r",
            height = "200px"
         )
      ),
      card(
         card_header("Value"),
         verbatimTextOutput("value")
      ),
      col_widths = c(6, 6)
   )
)

server <- function(input, output, session) {
   output$value <- renderText(input$code)
}

shinyApp(ui, server)

There's no space at the end of the line but the caret moves there:

Image
Session Info

─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.6.1 (2026-06-24 ucrt)
 os       Windows 11 x64 (build 22631)
 system   x86_64, mingw32
 ui       RTerm
 language (EN)
 collate  English_Switzerland.utf8
 ctype    English_Switzerland.utf8
 tz       Europe/Zurich
 date     2026-07-08
 pandoc   3.7.0.2 @ C:\\Users\\user\\APPS_O~1\\pandoc\\pandoc.exe
 quarto   1.9.38 @ C:\\Users\\user\\AppData\\Local\\Programs\\Quarto\\bin\\quarto.exe

─ Packages ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
! package * version date (UTC) lib source
P bslib * 0.11.0.9000 2026-07-08 [?] Github (rstudio/bslib@996f77e)
P cachem 1.1.0 2024-05-16 [?] CRAN (R 4.6.0)
P cli 3.6.6 2026-04-09 [?] CRAN (R 4.6.0)
P devtools 2.5.2 2026-04-30 [?] CRAN (R 4.6.1)
P digest 0.6.39 2025-11-19 [?] CRAN (R 4.6.0)
P ellipsis 0.3.3 2026-04-04 [?] CRAN (R 4.6.1)
P fastmap 1.2.0 2024-05-15 [?] CRAN (R 4.6.0)
P fs 2.1.0 2026-04-18 [?] CRAN (R 4.6.0)
glue 1.8.1 2026-04-17 [2] CRAN (R 4.6.1)
P htmltools 0.5.9 2025-12-04 [?] CRAN (R 4.6.0)
P httpuv 1.6.17 2026-03-18 [?] CRAN (R 4.6.0)
P jquerylib 0.1.4 2021-04-26 [?] CRAN (R 4.6.0)
P jsonlite 2.0.0 2025-03-27 [?] CRAN (R 4.6.0)
P later 1.4.8 2026-03-05 [?] CRAN (R 4.6.0)
P lifecycle 1.0.5 2026-01-08 [?] CRAN (R 4.6.0)
P magrittr 2.0.5 2026-04-04 [?] CRAN (R 4.6.0)
P memoise 2.0.1 2021-11-26 [?] CRAN (R 4.6.0)
P mime 0.13 2025-03-17 [?] CRAN (R 4.6.0)
otel 0.2.0 2025-08-29 [2] CRAN (R 4.6.1)
P pillar 1.11.1 2025-09-17 [?] CRAN (R 4.6.1)
P pkgbuild 1.4.8 2025-05-26 [?] CRAN (R 4.6.1)
P pkgconfig 2.0.3 2019-09-22 [?] CRAN (R 4.6.1)
P pkgload 1.5.3 2026-06-15 [?] CRAN (R 4.6.1)
P promises 1.5.0 2025-11-01 [?] CRAN (R 4.6.0)
P purrr 1.2.2 2026-04-10 [?] CRAN (R 4.6.1)
P R6 2.6.1 2025-02-15 [?] CRAN (R 4.6.0)
P Rcpp 1.1.2 2026-07-05 [?] CRAN (R 4.6.1)
renv 1.2.3 2026-05-16 [1] CRAN (R 4.6.1)
P rlang 1.3.0 2026-07-05 [?] CRAN (R 4.6.1)
P sass 0.4.10 2025-04-11 [?] CRAN (R 4.6.0)
P sessioninfo 1.2.4 2026-06-04 [?] CRAN (R 4.6.1)
P shiny * 1.14.0 2026-06-21 [?] CRAN (R 4.6.0)
P tibble 3.3.1 2026-01-11 [?] CRAN (R 4.6.1)
P usethis 3.2.1 2025-09-06 [?] CRAN (R 4.6.1)
P vctrs 0.7.3 2026-04-11 [?] CRAN (R 4.6.1)
withr 3.0.3 2026-06-19 [2] CRAN (R 4.6.1)
P xtable 1.8-8 2026-02-22 [?] CRAN (R 4.6.0)

[1] C:/Users/user/Documents/.renv/library/bslib-reprex/windows/R-4.6/x86_64-w64-mingw32
[2] C:/Users/user/AppData/Local/Programs/R/R-4.6.1/library

  • ── Packages attached to the search path.
    P ── Loaded and on-disk path mismatch.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Shiny reprex and compare the caret position with the visible end of each line. Read the implementation of input_code_editor() and the related issue #1303 to trace how the editor positions the caret. Done means the caret no longer appears after trailing visual space when the line has no trailing space.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.