Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion R/tribble_paste.R
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,10 @@ rstudio_context <- function(){
output_context <- list()
output_context$indent_head <- FALSE #head already at cursor
output_context$output_mode <- "rstudioapi"
output_context$nspc <-
output_context$nspc <- 4
if (rstudioapi::hasFun("readRStudioPreference")) {
rstudioapi::readRStudioPreference("num_spaces_for_tab", 4)
}
context <- rstudioapi::getActiveDocumentContext()
context_row <- context$selection[[1]]$range$start["row"]
if(all(context$selection[[1]]$range$start == context$selection[[1]]$range$end)){
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ There are two R functions available that accept R objects and output formatted t
* `dpasta` accepts tibbles, data.frames, and vectors. Data is output in a format that matches in input class. Formatted text is pasted at the cursor.

* `dmdclip` accepts the same inputs as `dpasta` but inserts the formatted text onto the clipboard, preceded by 4 spaces so that is can be as pasted as a preformatted block to Github, Stackoverflow etc.

## Use with Positron

`datapasta` works in Positron, but addins are not supported. You can use the functions directly from the console, or assign them keyboard shortcuts.
For example, to assign `datapasta::tribble_paste()` the shortcut <kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>t</kbd>, run the command **Preferences: Open Keyboard Shortcuts (JSON)** and add the following JSON to the array of shortcuts:

```json
{
"key": "Ctrl+Shift+t",
"command": "workbench.action.executeCode.console",
"when": "editorTextFocus",
"args": {
"langId": "r",
"code": "datapasta::tribble_paste()",
"focus": true
}
}
```


## Use with other editors

Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_rstudio.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test_that("readPreference() returns an integer", {
skip_on_travis()
skip_if_not(is_interactive)
skip_if_not(rstudioapi::isAvailable())
skip_if_not(rstudioapi::hasFun("readRStudioPreference"))
expect_equal(rstudioapi::readPreference('num_spaces_for_tab', 4), 4)

})