Skip to content

Commit 73ff451

Browse files
authored
Turn on workspace setting to trim trailing whitespace (#46)
* Trim trailing whitespace and show it when diffing * Trim trailing whitespace from error files
1 parent 69e42ae commit 73ff451

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.vscode/settings.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
"cmake.configureOnOpen": false,
1717
"rust-analyzer.showUnlinkedFileNotification": false,
1818
"files.insertFinalNewline": true,
19-
"files.trimFinalNewlines": true
19+
"files.trimFinalNewlines": true,
20+
"files.trimTrailingWhitespace": true,
21+
"diffEditor.ignoreTrimWhitespace": false
2022
}

crates/ark/src/lsp/modules/private/errors.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ handle_error_base <- function(cnd) {
4949
traceback <- lapply(traceback, function(lines) paste0(lines, collapse = "\n"))
5050
traceback <- as.character(traceback)
5151
traceback <- paste0(traceback, srcrefs)
52-
52+
5353
.ps.Call("ps_record_error", evalue, traceback)
5454
}
5555

@@ -120,7 +120,7 @@ path_trim_prefix <- function(path, n) {
120120
handle_error_rlang <- function(cnd) {
121121
evalue <- rlang::cnd_message(cnd, prefix = TRUE)
122122
traceback <- cnd$trace
123-
123+
124124
if (is.null(traceback)) {
125125
traceback <- character()
126126
} else if (rlang::trace_length(traceback) == 0L) {

crates/ark/src/lsp/modules/public/errors.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Unregister all handlers and hold onto them
1717
handlers <- globalCallingHandlers(NULL)
18-
18+
1919
# Inject our global error handler at the end.
2020
# This allows other existing error handlers to run ahead of us.
2121
handlers <- c(handlers, list(error = .ps.errors.globalErrorHandler))
@@ -27,7 +27,7 @@
2727
invisible(NULL)
2828
}
2929

30-
.ps.errors.globalErrorHandler <- function(cnd) {
30+
.ps.errors.globalErrorHandler <- function(cnd) {
3131
if (!is_installed("rlang")) {
3232
# rlang is not installed, no option except to use the base handler
3333
return(handle_error_base(cnd))
@@ -36,10 +36,10 @@
3636
# We have a non-rlang error, but the user requested we dont entrace it
3737
return(handle_error_base(cnd))
3838
}
39-
39+
4040
if (!inherits(cnd, "rlang_error")) {
4141
cnd <- rlang::catch_cnd(rlang::entrace(cnd))
4242
}
43-
43+
4444
handle_error_rlang(cnd)
4545
}

0 commit comments

Comments
 (0)