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

"cursor drift" on long lines, cursor position slowly shifts few pixels to left when editing long lines #14458

Open
4 tasks done
BdR76 opened this issue Mar 20, 2024 · 2 comments

Comments

@BdR76
Copy link

BdR76 commented Mar 20, 2024

System details

RStudio Edition : Desktop
RStudio Version : RStudio 2023.12.1 Build 402 
OS Version      : Windows 10 Home (64-bit)
R Version       : 4.3.1

Steps to reproduce the problem

  1. open the R script in the attachement in R studio
  2. observe that it cannot run line 62 (data$aaicdcode.factor..) because it it too long
  3. try to edit line 62 by adding a newline after the comma at "2774", (near line position 2000)
  4. observe that the line now ends with .."2774"," instead of .."2774",

Or more obviously:

  1. move the cursor to "4019", (near line position 5000)
  2. try to place cursor and change the text to "40x19",
  3. observe that the x is placed in a differnt location, most likely "4019x", or "4019"x,

Describe the problem in detail

We work with REDCap for data collection and Rstudio for data analysis. When exporting the data from REDCap it results in a csv file and an accompanying R script. For various reasons the generated R script can contain very long lines, like >4000 characters. These scripts cannot be executed as-is due to the long lines and Rstudio gives an error message which, if I understand correctly, is due to the console line limit (default=1000 lines).

It might be some other R or Rstudio setting, but in any case the work-around is to manually add new-lines, so break up the line with enter/return so that the lines don't exceed 4000 characters, and then the script can be executed correctly and without errors.

However, while editing these script files in Rstudio we noticed that on long lines as the cursor position increases on the line, it slowly shifts a few pixels to left of its actual position. For example this "cursor drift" is noticable when moving the cursor to .."7300", to after the comma and then pressing enter. The result is that the line now ends in .."7300","74 instead of .."7300",.

Or for example when setting the cursor before the 5 at "345000" and then pressing the a key. The result will be "3450a00" so it's inserted 2 characters to the right instead of where the visual cursor position. This is causing our researchers trouble when trying to run and edit these generated files.

See screenshots below, and I've included the generated script in the attachment.
rstudio_cursor_drift
CardioStudy-AnnualReport2024_R_2024-03-21_1324.txt <- rename to .R script

Describe the behavior you expected

I expected the cursor to edit the code at place it is visible, instead of off-by-X characters.

  • I have read the guide for submitting good bug reports.
  • I have installed the latest version of RStudio, and confirmed that the issue still persists.
  • (not applicable) If I am reporting an RStudio crash, I have included a diagnostics report.
  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
@BdR76 BdR76 added bug new New incoming issues, ready for initial review. labels Mar 20, 2024
@gtritchie gtritchie added the ace label Mar 20, 2024
@gtritchie
Copy link
Member

I was able to reproduce this both on 2023.12.1, and daily build 2024.04.0-daily+624.

Also reproduces in the Ace Kitchen sink. I opened an issue against Ace: ajaxorg/ace#5515

@ronblum ronblum removed the new New incoming issues, ready for initial review. label Mar 22, 2024
@BdR76
Copy link
Author

BdR76 commented Mar 25, 2024

fyi the separate but related issue of "scripts won't execute very long lines properly" when running lines with >4000 characters was addressed #14428 i.e. give a proper error/warning message when truncating lines, instead of incompletely parsing a line and then "failing silently" resulting in unrelated errors in subsequent code.

@ronblum ronblum added this to the Later milestone Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants