Skip to content

Cursor position is lost when moving from visual editor to source editor and vice versa #8411

Open

Description

@BartJanvanRossum

System details

RStudio Edition : Desktop
RStudio Version : 1.4.1032
OS Version      : Windows10
R Version       : 4.0.3

Steps to reproduce the problem

  • Create a new .Rmd file
  • Switch to visual editing
  • Click anywhere in the text
  • Switch to source editing
  • Note that the cursor is at the beginning of the document

Describe the problem in detail

The problem in itself should be quite clear from the steps to reproduce.

Note that the after editing some text in the visual editor, switching to source editing seems to keep the correct cursor position. However editing text in the source editor doesn't assure a correct cursor position after switching to visual editing.

Describe the behavior you expected

The cursor in the correct position when switching between modes.

  • 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.
  • If I am reporting a 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.

Activity

  1. ronblum commented on Nov 17, 2020

    @ronblum
    Contributor

    [Rewritten]
    @BartJanvanRossum Thank you for raising the issue! Is the cursor always jumping to the top of the document or to the beginning of a section or code block? This screen capture shows the behavior: https://tinyurl.com/yyt5rseg
    If so, this is known behavior. However, I'll leave this open as something to consider changing in the future. Please let me know if this isn't what you're seeing—specifically, that the cursor always jumps to the top.

  2. added
    visual markdown
    on Nov 17, 2020
  3. BartJanvanRossum commented on Nov 18, 2020

    @BartJanvanRossum
    Author

    Unfortunately I cannot access the screen capture. Clicking the link gives "Access denied".

    When I first noticed this behavior, it seemed the cursor always jumped to the top or the beginning of a section/code block. This would be annoying, but workable. However the actual behavior seems less consistent.

    E.g. try following these steps:

    • Create a new .Rmd file, default settings, html output
    • This opens in source mode.
    • Put the cursor before the T in the first section
    • Switch to visual mode
    • The cursor now is at the end of the yaml block at the start of the document
    • From this point on switching between visual and source mode the cursor will be at the beginning or the end of the yaml block, which is more or less what you describe.

    A second example, continuing with the same document:

    • In visual mode add a space between T and h in the first section
    • Switch to source mode
    • The cursor is at the correct position
    • Now, in source mode, add a space between h and i
    • Switch back to visual mode
    • The cursor is back to where it was left, so after the space between T and h

    I hope this makes clear what the problem is.

  4. stale commented on Feb 16, 2021

    @stale

    This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.

  5. added
    stale
    on Feb 16, 2021
  6. removed
    stale
    on Feb 22, 2021
  7. self-assigned this
    on Sep 13, 2021
  8. jennybc commented on Dec 6, 2022

    @jennybc
    Member

    I experience this regularly. It's hard to tell if there's any rhyme or reason re: where the cursor goes as I toggle back and forth. But here are some current examples:

    Example 1:

    • Start in Visual mode.
    • Put the cursor in the middle of some prose.
    • Switch to Source mode.
    • Now the cursor is at the start of the yaml front matter in the closest code chunk above the previous cursor location.
    • Switch back to Visual mode.
    • Cursor remains in the R chunk.

    Example 2:

    • Start in Visual mode.
    • Put the cursor in the middle of some prose.
    • Switch to Source mode.
    • Now the cursor is at the start of the closest heading above the previous cursor location.
    • Switch back to Visual mode.
    • Cursor remains in the R heading.

    This is probably too simple, but it feels like the cursor jumps to the closest # character above the current cursor location.

  9. modified the milestones: Backlog-2, Later on Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementvisual markdown

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions