Skip to content

Commit

Permalink
Merge pull request #144 from ManuelHentschel/help2
Browse files Browse the repository at this point in the history
Add ?? and fix some bugs
  • Loading branch information
ManuelHentschel authored Dec 24, 2020
2 parents b00b454 + a992aea commit 44a7c7d
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 5 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(.vsc.preBreakpoint)
export(.vsc.preDebugSourceBreakpoint)
export(.vsc.print)
export(.vsc.print.help_files_with_topic)
export(.vsc.print.hsearch)
export(.vsc.refreshBreakpoints)
export(.vsc.str)
useDynLib(vscDebugger,c_get_ppid)
Expand Down
1 change: 1 addition & 0 deletions R/defaultVarInfo.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ getDefaultVarInfos <- function() {
name = '.Random.seed',
doesApply = function(v) !is.null(v) && identical(v, get0(".Random.seed", globalenv())),
childVars = list(),
evaluateName = '.Random.seed',
nChildVars = 0
),
# R6 (TODO: display public/private properties etc.)
Expand Down
5 changes: 4 additions & 1 deletion R/evaluate.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ evaluateRequest <- function(response, args, request){
if(
valueAndVisible$visible
&& context != 'watch'
&& identical(class(valueAndVisible$value), 'help_files_with_topic')
&& (
identical(class(valueAndVisible$value), 'help_files_with_topic')
|| identical(class(valueAndVisible$value), 'hsearch')
)
){
valueAndVisible$visible <- FALSE
base::print(valueAndVisible$value)
Expand Down
7 changes: 7 additions & 0 deletions R/flow.R
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ sessionFinalizer <- function(...){
session$print_help_files_with_topic_0
)))
}
if(session$supportsHelpViewer && !is.null(session$print_hsearch_0)){
try(suppressWarnings(.S3method(
"print",
"hsearch",
session$print_hsearch_0
)))
}
try(detach(session$rStrings$attachName, character.only = TRUE), silent = TRUE)
try(sendExitedEvent(), silent = TRUE)
try(sendTerminatedEvent(), silent = TRUE)
Expand Down
2 changes: 1 addition & 1 deletion R/getStack.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ stackTraceRequest <- function(response, args, request){
# return:
response[['body']] <- list(
stackFrames = stackFrames,
totalFrames = length(frameIdsR)
totalFrames = max(length(frameIdsR), 1)
)
sendResponse(response)
}
Expand Down
19 changes: 19 additions & 0 deletions R/global.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@




#' vscDebugger
#'
#' Implementation of the Debug Adapter Protocol for R
#'
#' @docType package
#' @name vscDebugger-package
#'
#' @aliases vscDebugger2
#'
NULL




# create environment for global data used by package functions
session <- local({
# settings:
Expand Down Expand Up @@ -94,6 +112,7 @@ session <- local({
sourceBreakpointsList <- list()
sources <- list()
print_help_files_with_topic_0 <- NULL
print_hsearch_0 <- NULL
breakpointEnvironments <- list()


Expand Down
6 changes: 6 additions & 0 deletions R/launch.R
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ configurationDoneRequest <- function(response, args, request){
"help_files_with_topic",
.vsc.print.help_files_with_topic
))
session$print_hsearch_0 <- getS3method('print', 'hsearch')
suppressWarnings(.S3method(
"print",
"hsearch",
.vsc.print.hsearch
))
}

# disable just-in-time compilation (messes with source info etc.)
Expand Down
48 changes: 45 additions & 3 deletions R/overwrites.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ printToVsc <- function(ret, skipCalls=0, category="stdout", showSource=TRUE){

#' @export
.vsc.print.help_files_with_topic <- function(h, ...) {
success <- FALSE
if (length(h) >= 1 && is.character(h)) {
viewer <- getOption("vsc.helpPanel", "Two")
if (!identical(FALSE, viewer) && length(h) >= 1 && is.character(h)) {
file <- h[1]
path <- dirname(file)
dirpath <- dirname(path)
Expand All @@ -178,12 +178,54 @@ printToVsc <- function(ret, skipCalls=0, category="stdout", showSource=TRUE){
basename(file),
".html"
)
success <- sendCustomEvent('viewHelp', list(requestPath = requestPath))
success <- sendCustomEvent('viewHelp', list(requestPath = requestPath, viewer = viewer))
} else{
utils:::print.help_files_with_topic(h, ...)
}
invisible(h)
}


#' @export
.vsc.print.hsearch <- function(x, ...){
viewer <- getOption("vsc.helpPanel", "Two")
if (!identical(FALSE, viewer) && length(x) >= 1) {
requestPath <- paste0(
"/doc/html/Search?pattern=",
tools:::escapeAmpersand(x$pattern),
paste0("&fields.", x$fields, "=1",
collapse = ""
),
if (!is.null(x$agrep)) paste0("&agrep=", x$agrep),
if (!x$ignore.case) "&ignore.case=0",
if (!identical(
x$types,
getOption("help.search.types")
)) {
paste0("&types.", x$types, "=1",
collapse = ""
)
},
if (!is.null(x$package)) {
paste0(
"&package=",
paste(x$package, collapse = ";")
)
},
if (!identical(x$lib.loc, .libPaths())) {
paste0(
"&lib.loc=",
paste(x$lib.loc, collapse = ";")
)
}
)
success <- sendCustomEvent('viewHelp', list(requestPath = requestPath, viewer = viewer))
} else{
utils:::print.hsearch(x, ...)
}
invisible(x)
}

#' Refresh Breakpoints
#'
#' Refresh breakpoints known to the debugger
Expand Down
1 change: 1 addition & 0 deletions d.ts/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export interface Session {
sourceBreakpointsList: Breakpoints.SourceBreakpoints[];
sources: InternalSource[];
print_help_files_with_topic_0: RFunction | null;
print_hsearch_0: RFunction | null;
breakpointEnvironments: REnvironment[];
}

Expand Down
10 changes: 10 additions & 0 deletions man/vscDebugger-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 44a7c7d

Please # to comment.