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

Control where text is injected? #1

Open
homerhanumat opened this issue Jan 22, 2016 · 7 comments
Open

Control where text is injected? #1

homerhanumat opened this issue Jan 22, 2016 · 7 comments

Comments

@homerhanumat
Copy link
Owner

Mentioned by @rpruim: some code got injected into his .gitignore file.

Would it be possible to check the the type of file that is active, and to inject only if it is, say, .R or .rmd?

@rpruim
Copy link

rpruim commented Jan 22, 2016

My suggestion is simply that under the "done" button some text display informing the user where the injection will occur. That can help new users understand that injection will happen and also avoid errors that occur when the user mistakenly has the incorrect file open when the process begins.

If you try to restrict to certain types of files, someone will eventually be annoyed that they can't inject into some file they are using that you didn't anticipate. But perhaps a confirmation dialogue could be used in that situation instead of an absolute block.

@homerhanumat
Copy link
Owner Author

Yes, I could see some javascript here: if filetype is not R or rmd, rise
an alert.

On Fri, Jan 22, 2016 at 11:06 AM, Randall Pruim [email protected]
wrote:

My suggestion is simply that under the "done" button some text display
informing the user where the injection will occur. That can help new users
understand that injection will happen and also avoid errors that occur when
the user mistakenly has the incorrect file open when the process begins.

If you try to restrict to certain types of files, someone will eventually
be annoyed that they can't inject into some file they are using that you
didn't anticipate. But perhaps a confirmation dialogue could be used in
that situation instead of an absolute block.


Reply to this email directly or view it on GitHub
#1 (comment)
.

@rpruim
Copy link

rpruim commented Jan 22, 2016

Or Rnw

@homerhanumat
Copy link
Owner Author

yep.

On Fri, Jan 22, 2016 at 11:45 AM, Randall Pruim [email protected]
wrote:

Or Rnw


Reply to this email directly or view it on GitHub
#1 (comment)
.

@homerhanumat
Copy link
Owner Author

Randall,

Dany and I will be at that ShinyDev Conference. We can ask about some of
those features.

Homer

On Fri, Jan 22, 2016 at 11:45 AM, Randall Pruim [email protected]
wrote:

Or Rnw


Reply to this email directly or view it on GitHub
#1 (comment)
.

@rpruim
Copy link

rpruim commented Jan 22, 2016

Wish I could join you.

@homerhanumat
Copy link
Owner Author

Thinking a bit more about this issue.

The code will be injected into whichever document in the Source window is active, even if the user's focus is elsewhere (e.g., if the user has the cursor in the console). New users can easily get dinged by this.

The best I can think of now is to add some text to the label of the Done button, so that it reads:

Done (inject code into active source document)

rstudioapi::getActiveDocumentContext() can tell me the filename of the active document, provided it has one. The observer that handles input$done can check the filename extension and cause the app to raise an alert box warning the reader that the active document does not appear to be an R script or R Markdown or Rnw.

How does that sound?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants