Code cells in .R files#662
Code cells in .R files#662renkun-ken merged 3 commits intoREditorSupport:masterfrom ElianHugh:code-cells-PR
Conversation
Implements jupyter code block style decorators for .R files, uses rmd code lens
src/rmarkdown.ts
Outdated
| if (text.match(/^\s*```+\s*\{\w+\s*.*$/g)) { | ||
| return true; | ||
| function isRDocument(document: TextDocument) { | ||
| return (languages.match('r', document) > 0); |
There was a problem hiding this comment.
Is there a difference using document.languageId instead of languages.match('r', document) > 0?
There was a problem hiding this comment.
I haven't found any difference, thanks for picking that up! Not sure what the use case would be if languageId exists
src/rmarkdown.ts
Outdated
| CancellationToken, CodeLens, CodeLensProvider, | ||
| CompletionItem, CompletionItemProvider, | ||
| Event, EventEmitter, Position, Range, TextDocument, TextEditorDecorationType, window, Selection | ||
| Event, EventEmitter, Position, Range, TextDocument, TextEditorDecorationType, window, Selection, languages |
There was a problem hiding this comment.
languages seems unnecessary now.
|
Thanks for implementing this! Was wondering if it wouldn't be too much trouble to make cell delimiters single For example, percent scripts produced by jupytext currently skip alternate cells because the I'm assuming this is because the current implementation replaces the rmarkdown ``` delimiter with Also, seems like the shortcut to run chunk doesn't work for R scripts fenced by |
|
Thank you for the feedback! Just to be 100% clear on expected functionality, would it work like the following: i.e., a chunk continues until a new chunk is defined via |
|
Yep, exactly. Since there are no text blocks in scripts, there's no need for a separate bottom delimiter. |
|
Thanks for this excellent feature. Can the background between both |
|
|
Thanks! renkun! I didn't realize this is the same with rmarkdown. In this case, the problem raised in #901, which indicated |
|
Could you try changing the |
|
yeah, this can work. I have tried it last night. Just post here to let @ElianHugh know. |
|
@ElianHugh Looks like we should allow all these commands to run in both |
|
@renkun-ken, thanks for your help. I find the paranthesis is not supported in when clause, as pointed in microsoft/vscode#91473. so the when clause here should be |
|
Seems like a good change to me! I'd like to push this along with some of the jupyter code cell changes, but feel free to push a change sooner if needed |


Implements jupyter code block style decorators for .R files, piggybacking on the previous rmarkdown code lens implementation.
What problem did you solve?
Closes #191
Screenshot
(If you do not have screenshot) How can I check this pull request?
Open .R file, and make a code block like so:
Markdown code fences should not work in .R files, and the new decorator should not work in rmd files