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

Some short-cut keys don't work in the script window #8301

Closed
rdstern opened this issue May 2, 2023 · 5 comments
Closed

Some short-cut keys don't work in the script window #8301

rdstern opened this issue May 2, 2023 · 5 comments

Comments

@rdstern
Copy link
Collaborator

rdstern commented May 2, 2023

@lloyddewit I have been using multiple script windows recently and all seems to be going well.

But C for copy and X for cut don't seem to work. I think all the others are ok.

And, though I know it is a different topic I have found a very nice discussion on splitting a long line into multiple lines. I think this will work nicely in R-Instat, but I wonder what to do in "the opposite situation".

So first what I think works well. Namely you can split over multiple lines as long as R knows the command isn't finished.

So x <- 2 + 3 +
4
Is fine and R is happy, but don't do:
x <- 2 + 3

  • 4

A second example is

x <- ( 2 + 3
)/4

but not x <- (2 + 3)
/4

I like all this. But sometimes the code I run has accidentally more open brackets than closed brackets. Then, of course, R-Instat "appears to hang". Then I need to put a line with just a close bracket by itself and - then relief - I usually get an error.

Am I right that absence of a close bracket is the usual reason for hanging oddly like this? And also that the "solution" when you think it is hanging - because it might just be slow in executing - is to add a close bracket, because there is no other indication that it is waiting for me - rather than me waiting for it to execute?

@rdstern rdstern added this to the 0.7.11 milestone May 2, 2023
@lloyddewit
Copy link
Contributor

@rdstern

[ctrl] C for copy and [ctrl X] for cut don't seem to work. I think all the others are ok.

I tested and confirmed the same behaviour. These short cuts used to be provided by the third-party control I used for the text part. I'll investigate and add the functionality myself if needed.

you can split over multiple lines as long as R knows the command isn't finished.

For the examples you gave, I think the script window's behaviour is correct.

However the behaviour is far from perfect. Currently ctrl-Enter just adds the current line to a buffer. If it thinks the buffer is a valid R statement, then it executes it and clears the buffer. It uses heuristics (such as hanging binary operators, missing brackets etc.) to judge if the buffer contains a valid statement. However this sometimes fails.

I plan to improve the script window's back-end so that it uses the RScript library to find the complete statement at the cursor, execute the statement and then move the cursor to the start of the next statement. This is also what RStudio does and should solve the issues related to multi-line statements. This is documented in issue #7989.

@rdstern
Copy link
Collaborator Author

rdstern commented May 23, 2023

@lloyddewit I am adding a different question here as perhaps it could be considered at the same time that you fix the keys above. And I am not even sure it is much of an issue. This is the Save and Save As keys/facilities.

We have 3 main bits to save in R-Instat, namely data, output and scripts. Now, saving the data is simple in that it saves all the Tabs (data frames). We have the File > Save As > Save Data As, and that works almost fine. There is also a Save Button on the Toolbar and that is a Save, rather than Save As. And I use it, and would like to encourage others users to also do that regularly.

Now the script and output windows are both now tabbed! You have a Save button (and Save Script is also on the right-click). And the output Windows also have a Save button, and may have a right-click later.
I think, in each case, they only save a given Tab? And in the output window I think the button is a Save As button, for that Tab. Am I right on this?

I am probably making a meal of this, but I would like to make sure I have understood correctly and be able to explain this all to users. And I think we are pretty unusual in having so many separate bits to perhaps save, or not?

As I write this, I wonder whether each of the Script and Output Windows should have both a Save As and also a Save button. In each case Save As is just (as the Save now) for that Tab, while the Save is (as usual) the same as Save As if the current Tab has not been saved, but is also an update of all the previously saved tabs?

For most users this will be a no change, but it will mean there are just 3 well defined parts to save - I wonder what RStudio does? I am probably getting carried away now, but (if we go further, then we could add a down arrow to the Save button. This would then have 3 (or perhaps 4) options, namely

Save Data
Save Current Script
Save Current output
Save All

The Save All would then be a Save As for the data and each tab in each of the 3 windows. If they have all been previously saved, then it would just be a Save and would update them all!

(By the way, when we next change the toolbar, I would like to widen all the down arrows and also delete the Copy and Paste items. (We don't encourage that! - even though I am very keen that Patrick completes his current Paste pull request. One of the top items for the sprint!)

@rdstern rdstern modified the milestones: 0.7.11, 0.7.16 - mid August May 29, 2023
@rdstern
Copy link
Collaborator Author

rdstern commented Jun 8, 2023

@lloyddewit I also find that the Run button doesn't seem to work and neither does <ctrl><Enter> At least they both work if I mark the line, or the selection, but not otherwise. Perhaps this is similar to the C. limitation?

@rdstern
Copy link
Collaborator Author

rdstern commented Jul 16, 2023

@lloyddewit I wonder what remains here. Should this issue be re-titled or perhaps closed?

@lloyddewit
Copy link
Contributor

Most of the above is implemented. I moved the non-implemented part to issue #8454 .

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

2 participants