Skip to content

Commit

Permalink
silence uninformative error after no selection
Browse files Browse the repository at this point in the history
prevents:

```
Error in if (selection$range$end[["column"]] == 1L) { :
  argument is of length zero
```

The same error is shown in the dialog box.
  • Loading branch information
simonpcouch committed Nov 25, 2024
1 parent 91de88b commit 93eb90c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions R/rstudioapi.R
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ get_primary_selection <- function(context) {
selection <- rstudioapi::primary_selection(context)

if (selection[["text"]] == "") {
rstudioapi::showDialog("Error", "No code selected. Please highlight some code first.")
return(NULL)
stop("No code selected. Please highlight some code first.", call. = FALSE)
}

selection
Expand Down

0 comments on commit 93eb90c

Please sign in to comment.