-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make R side of editor handler more robust * Make Rust side of editor handler more robust
- Loading branch information
1 parent
bc638ad
commit 47bbc42
Showing
4 changed files
with
109 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# options.R | ||
# | ||
# Copyright (C) 2023 Posit Software, PBC. All rights reserved. | ||
# | ||
# | ||
|
||
handler_editor <- function(file, title, ..., name = NULL) { | ||
# `file.edit()` calls this as `editor(file = file, title = title)` | ||
# `edit()` calls this as `editor(name = name, file = file, title = title)` | ||
|
||
if (!is.null(name)) { | ||
stop("Editing objects is not currently supported.", call. = FALSE) | ||
} | ||
|
||
if (identical(file, "")) { | ||
# i.e. `edit()` with no arguments. Also `file.edit("")`. | ||
# Opens a temporary file for editing. | ||
file <- tempfile(fileext = ".txt") | ||
} | ||
|
||
file <- as.character(file) | ||
title <- as.character(title) | ||
|
||
# Get absolute path to file | ||
file <- normalizePath(file, mustWork = FALSE) | ||
|
||
# Make sure the requested files exist, creating them if they don't | ||
ensure_file(file) | ||
|
||
# Edit those files. | ||
.ps.Call("ps_editor", file, title) | ||
|
||
invisible() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters