positron
positron copied to clipboard
R debugger: starting debugger prompts file saving
Positron Version:
Positron Version: 2023.10.0 (Universal) build 1453 Code - OSS Version: 1.83.0 Commit: b781e9e92c1fe27c2160a8d5f852671f24884cb4 Date: 2023-10-30T03:03:08.650Z Electron: 25.8.4 ElectronBuildId: undefined Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 22.6.0
Steps to reproduce the issue:
- make debugger happen in unsaved file.
I ran
debugonce(lm)
lm(mpg ~ disp, data = mtcars)
https://github.com/posit-dev/positron/assets/14034784/7d5649a9-15ac-4280-afd9-b9ea2f7eac88
What did you expect to happen?
For this prompt not to happen
Were there any error messages in the output or Developer Tools console?
Nope
I'm not sure if this is a good or bad thing tbh!
On one hand, being in a debugger state is inherently a little unstable regardless of what language you do it in, so encouraging a saved file seems reasonable.
On the other hand, I often want to quickly debug something in vctrs so I'll open a new scratch file, type in some code that i know will trigger the issue, run debugonce(fn) in the console, then run that code in the scratch file, and saving seems like overkill there
I think I convinced myself we should look into avoiding this save prompt, because of how often I do the "quick debug" in a scratch file
See https://github.com/microsoft/vscode/issues/77023 where Debug: Save Before Start is mentioned as an option to control this, I think that should help
I think it'd make sense to set the default to "save non-untitled files" in Positron:
What do you think @juliasilge?
Can we try having the R extension just contribute it for .R files? As a way to reduce the impact for other debuggers and similar to https://github.com/PowerShell/vscode-powershell/issues/3200, adding something like this:
"[r]" : {
"debug.saveBeforeStart": "nonUntitledEditorsInActiveGroup"
}
to here:
https://github.com/posit-dev/positron/blob/47dda03439f0c94bf3e47f28e8da7e9bdb516be7/extensions/positron-r/package.json#L350
We discussed this internally and came to these conclusions:
Changing the default for one language has usability issues because these defaults have precedence over global settings set by the user. As a user it's surprising to find that a setting does not work in some files, and it's not obvious that the reason is a language override set by an extension. For this reason we prefer to avoid such language override set by extensions, and instead change the global default in the core, if it makes sense to do so for all languages.
We've polled Python users in our Slack channel and they don't think changing the default to nonUntitledEditorsInActiveGroup would be disruptive to their workflow. So we're going to do that as we think this is going to improve UX for all users of Positron.
@lionel- If I understand correctly, the expected behavior now is for file to be automatically saved once file is run, correct?
No, they don't get saved:
Untitled scratch files should no longer prompt a save dialog when a debug session is started (e.g. via
browser()in R). Titled files should still be saved by default and silently when the session starts.
Yes, titled file is being saved by default and silently when session starts. It doesn't prompt me to save (it's automatic).