microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.11k stars 29.27k forks source link

Restoration of unsaved open editors on FreeBSD #136409

Closed grahamperrin closed 2 years ago

grahamperrin commented 3 years ago

Issue Type: Bug

With Code - OSS on FreeBSD, on at least three occasions I have lost all unsaved opened editors.

https://stackoverflow.com/q/69335518/38108 recalls a September incident. The most recent incident was this week.

For the two most recent incidents, I'm almost certain that losses were noticeable after a file was opened into Code - OSS by some other application.

It's possible/likely that Code - OSS was not running prior to opening of the file.

Also, it's possible that the computer was unusually busy at the times of the incidents.

VS Code version: Code - OSS 1.56.2 (054a9295330880ed74ceaedda236253b4f39a335, 2021-10-10T20:11:12.799Z) OS version: FreeBSD x64 14.0-CURRENT

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz (4 x 2893)| |GPU Status|2d_canvas: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
oop_rasterization: disabled_off
opengl: enabled_on
rasterization: disabled_software
skia_renderer: enabled_on
video_decode: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled| |Load (avg)|2, 4, 4| |Memory (System)|15.88GB (0.33GB free)| |Process Argv|--no-sandbox --unity-launch --no-sandbox| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|/usr/local/share/xsessions/plasma| |XDG_CURRENT_DESKTOP|KDE| |XDG_SESSION_DESKTOP|KDE| |XDG_SESSION_TYPE|x11|
Extensions (20) Extension|Author (truncated)|Version ---|---|--- better-comments|aar|2.1.0 msg|ajs|0.1.1 vscode-office|cwe|1.9.1 ini-for-vscode|Dav|0.0.4 reg|ion|1.0.3 pdf|k5h|4.2.3 wordcounter|Lud|0.0.1 vscode-language-pack-en-GB|MS-|1.54.1 vscode-ros|ms-|0.6.9 python|ms-|2021.5.926500501 vscode-pylance|ms-|2021.7.7 jupyter|ms-|2021.6.832593372 cpptools|ms-|1.5.1 languagetool|ray|1.0.1 rewrap|stk|1.14.0 zip-file-system|Tom|2.0.0 pdf|tom|1.1.0 reflow-paragraph|Tro|1.3.0 txt-syntax|xsh|0.2.0 vscode-aspell|zap|0.1.4

Makefile and other files for the port to FreeBSD (editors/vscode) are at https://cgit.freebsd.org/ports/tree/editors/vscode.

grahamperrin commented 3 years ago

Symptoms (not necessarily this bug) are reproducible:

  1. have one unsaved open editor, nothing else open in Code - OSS
  2. exit/quit
  3. use the context menu of a file manager e.g. Dolphin to open a file in Code - OSS
  4. key Control-Q too soon – before the application has an opportunity to reopen the unsaved editor
  5. open Code - OSS
  6. observe the file that was opened at step (3) – alone, without the previously open unsaved editor.

Step (4) is unnatural, but enough to cause disappearance.

grahamperrin commented 3 years ago

VS Code version: Code - OSS 1.56.2

Re: https://code.visualstudio.com/updates/ with 1.56.2 at April 2021 on the timeline, I sped through linked issues for more recent versions.

Just one issue caught my eye – 125970, involving avoidance of race conditions and multiple windows.


To the best of my knowledge: this issue 136409 does not involve multiple windows. Still, I wonder about race conditions.

bpasero commented 3 years ago

@grahamperrin we do not restore sessions with unsaved files when a single file is opened, rather we ask you do open that workspace again where the unsaved files are in to continue working on them. This was a change we did once by accident and then couldn't change it back because users got a ton of windows opened at the same time.

If you have steps for data loss that is different, please let me know.

Btw you can configure this setting to always restore all windows, even when a single file is opened: window.restoreWindows: preserve

grahamperrin commented 3 years ago

we do not restore sessions with unsaved files when a single file is opened

Here: unsaved editors are reopened, without interaction, when a single (saved) file is opened, with the following window.restoreWindows preference, which I probably never changed:

image

So, have I become accustomed to buggy behaviour (unexpected opening)?

bpasero commented 3 years ago

Then maybe I have misunderstood the issue, can you provide some step by step instructions of what you see and what you would expect?

gjsjohnmurray commented 3 years ago

@grahamperrin can you rebuild your OSS FreeBSD port from the current release (1.61.2) and still reproduce the issue?

grahamperrin commented 3 years ago

can you rebuild your OSS FreeBSD port from the current release (1.61.2) …

Probably out of my depth, sorry.

… step by step instructions of what you see …

window.restoreWindows all (the default)

  1. Have one unsaved editor comprising the word blah
  2. quit
  3. in Dolphin, double-click a .log file
  4. Code - OSS opens the file (uppermost)
  5. the unsaved editor is restored, below:

image

window.restoreWindows preserve

  1. Have one unsaved editor comprising the word blah
  2. quit
  3. in Dolphin, double-click a .log file
  4. Code - OSS restores the unsaved editor (uppermost)
  5. the double-clicked file appears, below:

image

grahamperrin commented 3 years ago

… what you would expect? …

I'm no longer certain.

Today I discovered the Files: Auto Save preference. I see https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save but can't tell whether this preference is intended to apply to an editor that has never been saved.

bpasero commented 3 years ago

Auto save setting only applies to saved files, but you can configure files.hotExit: off to get asked to save when closing.

grahamperrin commented 3 years ago

Thank you.

So, I learnt to expect restoration of unsaved editors – the first set of five steps to reproduce under https://github.com/microsoft/vscode/issues/136409#issuecomment-962580436 however:

https://github.com/microsoft/vscode/issues/136409#issuecomment-960475659

we do not restore sessions with unsaved files when a single file is opened, …

– is it wrong for restoration to occur with those steps?

we ask you do open that workspace again where the unsaved files are in to continue working on them. …

Should a dialogue appear?

I never thought of the unsaved editors as being in a workspace. (Maybe I never used/saved a workspace. I should probably describe myself as a casual but frequent user of the application; not a developer.)

bpasero commented 3 years ago

Our rule today is:

Without a clear suggestion what to change in this flow here or without a clear bug with this flow I am not sure how to proceed.

grahamperrin commented 2 years ago
  • if you had an empty workspace opened (no folder opened) and you leave it with dirty files, …

If dirty means never saved, then (yes) that's most often my use case.

we restore it …

Occasional disappearance (or non-restoration, I'm not sure which) was the rationale for me opening this issue.

https://github.com/microsoft/vscode/issues/136409#issuecomment-960547873

can you rebuild your OSS FreeBSD port from the current release (1.61.2) and still reproduce the issue?

https://github.com/tagattie/FreeBSD-VSCode/issues/35#issuecomment-980547075 1.62.3 is ported but not yet packaged for FreeBSD 14.0-CURRENT. I'll review in due course.

Thanks