diff --git a/R/session/vsc.R b/R/session/vsc.R index f2c4c1ed0..6409b0ef7 100644 --- a/R/session/vsc.R +++ b/R/session/vsc.R @@ -515,21 +515,24 @@ show_browser <- function(url, title = url, ..., "Opening in external browser..." ) request_browser(url = url, title = title, ..., viewer = FALSE) - } else if (file.exists(url)) { - url <- normalizePath(url, "/", mustWork = TRUE) - if (grepl("\\.html?$", url, ignore.case = TRUE)) { - message( - "VSCode WebView has restricted access to local file.\n", - "Opening in external browser..." - ) - request_browser(url = path_to_uri(url), - title = title, ..., viewer = FALSE) + } else { + path <- sub("^file\\://", "", url) + if (file.exists(path)) { + path <- normalizePath(path, "/", mustWork = TRUE) + if (grepl("\\.html?$", path, ignore.case = TRUE)) { + message( + "VSCode WebView has restricted access to local file.\n", + "Opening in external browser..." + ) + request_browser(url = path_to_uri(path), + title = title, ..., viewer = FALSE) + } else { + request("dataview", source = "object", type = "txt", + title = title, file = path, viewer = viewer) + } } else { - request("dataview", source = "object", type = "txt", - title = title, file = url, viewer = viewer) + stop("File not exists") } - } else { - stop("File not exists") } }