You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cursor position is lost when moving from visual editor to source editor and vice versa #8411
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.
[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.
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 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.
Activity
ronblum commentedon Nov 17, 2020
[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.
BartJanvanRossum commentedon Nov 18, 2020
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:
A second example, continuing with the same document:
I hope this makes clear what the problem is.
stale commentedon Feb 16, 2021
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.
jennybc commentedon Dec 6, 2022
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:
Example 2:
This is probably too simple, but it feels like the cursor jumps to the closest
#character above the current cursor location.