Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ark: Opening >1 files with file.edit() fails #857

Open
DavisVaughan opened this issue Jul 13, 2023 · 3 comments
Open

ark: Opening >1 files with file.edit() fails #857

DavisVaughan opened this issue Jul 13, 2023 · 3 comments
Labels
bug Something isn't working lang: r

Comments

@DavisVaughan
Copy link
Contributor

file.edit("/Users/davis/files/programming/netlify/netlify-pat.txt", "/Users/davis/files/programming/cpp/date/CMakeLists.txt")
#> Error in `dir.create()`:
#> ! invalid 'path' argument

Due to ensure_directory() only accepting a single file path at a time
https://github.com/posit-dev/amalthea/blob/7ccaa2678e79a2a49ecb7420b8ec4db533404171/crates/ark/src/modules/private/tools.R#L16-L22

@DavisVaughan DavisVaughan added this to the Internal Preview milestone Jul 13, 2023
@DavisVaughan
Copy link
Contributor Author

It seems like if you patch up ensure_directory() with something like

ensure_directory <- function(path) {
    lapply(path, function(x) dir.create(x, showWarnings = FALSE, recursive = TRUE))
}

then it still doesn't work quite right because the first file opens but its tab is then overwritten by the second file

@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented Jul 13, 2023

It seems like they don't both stay open because they are opened as preview editors

(you can tell because the filename is in slanted italics)

In the settings if I turn workbench.editor.enablePreview to false then it works as expected and opens both files

@DavisVaughan
Copy link
Contributor Author

DavisVaughan commented Jul 14, 2023

Adding a note that a show_document() request is eventually handled by this in the languageserver package IIUC
https://github.com/microsoft/vscode-languageserver-node/blob/2041784436fed53f4e77267a49396bca22a7aacf/client/src/common/client.ts#L1158

And that calls back into vs code's window.showTextDocument() command, which is defined here
https://github.com/microsoft/vscode/blob/80b3fcc08deccbbd4e4f844762f905ef78692a8c/src/vscode-dts/vscode.d.ts#L9793-L9802

showTextDocument() does accept TextDocumentShowOptions, which has an option for preview.
https://github.com/microsoft/vscode/blob/80b3fcc08deccbbd4e4f844762f905ef78692a8c/src/vscode-dts/vscode.d.ts#L752-L779

Unfortunately I don't see any way for us to set that to false through the LSP show_document() API.


Eventually all of this ends up getting passed to doOpenEditor() here:
https://github.com/rstudio/positron/blob/2b90a899b91602e0029561df2e8676a467c9b815/src/vs/workbench/browser/parts/editor/editorGroupView.ts#L985-L990

Where !preview is mapped to options.pinned there.

And if preview was left undefined then in this case pinned ends up being false unless enablePreview = false is also set by the user.


It does look like they allow for a middleware hook here
https://github.com/microsoft/vscode-languageserver-node/blob/2041784436fed53f4e77267a49396bca22a7aacf/client/src/common/client.ts#L1182C11-L1187

where in theory we could force preview = false but I feel like that is a sledgehammer for this kind of issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lang: r
Projects
None yet
Development

No branches or pull requests

2 participants