Post

2 followers Follow
0
Avatar

accidental deletion in source code

I am very happy with most of RStudio's behavior except for one thing that drives me crazy at least once a aday. Here's what happens:

1) load a source file
2) highlight a few lines of code in that file
3) click the run button
4) observe stuff happening in the console
5) eagerly start typing to continue interactively

EEK! I've just deleted 20 lines of source code!

Now I have to Click-Edit, Click-Undo for every character I have typed to get back to where I was. AARRRGH!

frustration.level <- rep(c("click","click"), nchar(recent_typing))

Whew! Let's start over ... 1, 2, 3, 4, 5 ... OH NO! I did it again!!!

Clearly, I am a creature of habit, but I have talked to several other people who have had exactly the same frustration.

Two features would solve this problem:

A) have the focus jump to the console after clicking the Run button. (Similar behavior to the "To Source" button in the History tab.)
B) provide undo/redo arrow buttons to reduce two clicks to one

Thanks!

Ian Pylvainen

6 comments

0
Avatar

Jonathan,

Thanks for the feedback and sorry this is so painful for you. When you highlight a selection and accidentally delete it by pressing another key, is it not enough to perform edit | undo once to get your code back? Also to save time, I'd personally suggest using the shortcut Ctrl+Z to quickly undo any mistakes rather than using the menu item.

Either way, this isn't a solution for problem (just trying to clarify what is going on). We've got a feature request to toggle the focus after a run to either the console of the source. Originally, we actually had it as you suggested (place focus in the console after a run), but got a lot of negative feedback on this due to the majority of users working primarily in the source (editing, running, and editing again all in the source rather than the console). This was for reproducibility purposes as well as ease of use.

As you've suggested, I'll chalk up another request on this feature suggestion to allow the user to choose the behavior. Also one for placing the undo button on the menu.

Josh

Ian Pylvainen 0 votes
0
Avatar

Josh,

Thanks for the quick response and for the Ctrl+Z hint. This shortcut is
way more efficient than clicking on any button.

But just FYI, I need to Ctrl+Z once for each character I have typed rather
than once for the entire chunk. I believe I saw mention of this as being
dependent upon your use of the Ace editor.

And it's interesting to hear that most people stay in the source window.
I'm always bouncing back and forth, especially when I'm trying to debug
some source code. In that scenario I will highlight and run in the source
and then go into the console to examine various results, then highlight and
run some more as I work my way through a file. Poor mans' break points!

Keep up the good work with Rstudio. Despite my suggestion I love what you
have created!

Jon

Ian Pylvainen 0 votes
0
Avatar

Jon,

Thanks for following up and I see what you mean by having to undo each character you've typed after the deletion. Thus, this just depends on how much you've typed before you realize it's deleted your selection. For example:

  • highlight selection
  • run
  • start typing: "foo <- "
  • realize you've deleted your code
  • undo 7 times

(Also yes, we use ACE for our editor)

Finally, I guess everyone has different working habits and I'd assume everyone jumps back and forth between the console at some point. Perhaps some just work in the source more than others. Either way, I've got the feature suggestion and thanks for the addition push for this.

Josh

Ian Pylvainen 0 votes
0
Avatar

Josh,

One quick note on this topic. I hadn't realized that Ctrl+Z was listed in
the Edit menu whereas "Clear console" does list Ctrl+L. It might be time
to go through those menus and make sure that all shortcuts are listed.

Jon

Ian Pylvainen 0 votes
0
Avatar

Jon,

Thanks for the heads up and this is actually just a QT thing. Unfortunately, we can't do anything about this right now. As far as I know, we've got the shortcuts listed for everything we can. The ones that have problems with QT are cut, copy, paste, undo, redo, and Find/Replace.

Josh

Ian Pylvainen 0 votes
0
Avatar

Jon

We've recently implemented this feature and now we've done two things:

1) Given the option to place focus into the console after executing lines of code from the source

2) Remove the selection after highlighting and running multiple lines from source

Both of these are aimed at removing the possibility of overwriting code after running a selection. This will be available in the next version of RStudio (v0.97) or if you want this feature now, you can download the latest daily:

http://www.rstudio.org/download/daily/

Josh

Ian Pylvainen 0 votes