From 7856df575b14dc2dcc490037f3ccf6fae533b0fc Mon Sep 17 00:00:00 2001 From: Romain Francois Date: Wed, 7 Feb 2024 08:37:39 +0100 Subject: [PATCH] polish breadcrumbs closes #1 --- DESCRIPTION | 2 ++ R/peek.R | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 54a665a..12f9277 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,4 +15,6 @@ URL: https://github.com/tadascience/snitch, http://tada.science/snitch/ BugReports: https://github.com/tadascience/snitch/issues Imports: cli, + glue, + rlang, stringr diff --git a/R/peek.R b/R/peek.R index 25fc492..61e82a4 100644 --- a/R/peek.R +++ b/R/peek.R @@ -4,7 +4,13 @@ breadcrumbs <- function() { snitched <- sapply(frames, function(f) exists(".__snitch", f, inherits = FALSE)) crumbs <- sapply(calls[snitched], function(call) { - as.character(call[[1L]]) + if (rlang::is_call(call[[1L]], "::")) { + glue::glue("{pkg}::{fun}", pkg = call[[1L]][[2L]], fun = call[[1L]][[3L]]) + } else if (rlang::is_call(call[[1L]], ":::")) { + glue::glue("{pkg}:::{fun}", pkg = call[[1L]][[2L]], fun = call[[1L]][[3L]]) + } else { + as.character(call[[1L]]) + } }) # TODO: figure out why eval is in there in the first place