github / vscode-codeql

An extension for Visual Studio Code that adds rich language support for CodeQL
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-codeql
MIT License
427 stars 189 forks source link

Limitations of Source Archive file systems #500

Open jcreedcmu opened 4 years ago

jcreedcmu commented 4 years ago

To Reproduce Import a database with a zipped archive. Open some file on disk outside the source archive. Select various source files in the source archive. Do VS Code command palette "Go Back"

Expected behavior The previously viewed file is shown.

Actual behavior The most recently viewed file outside the source archive is shown.

Additional context Users have reported that this bug doesn't consistently reproduce, and sometimes Go Back and Go Forward is broken even for normal files. A workaround is making the source archive file a non-preview editor, for example by double clicking on it in the file explorer.

Note that this is just one manifestation of the bug. For more context see https://github.com/github/vscode-codeql/issues/500#issuecomment-712301680 below.

aeisenberg commented 4 years ago

Here's how I can reliably reproduce:

  1. Close all editors except for editor A
  2. Open an archive file B in a preview editor
  3. Open a different archive file C in a preview editor
  4. run the Go Back command

Expected: navigates to location in B.

Actual: navigates to A.

Note that if B is converted to non-preview, then navigation happens as expected.

aeisenberg commented 4 years ago

My thinking is that this is a vscode bug. I can't see any code path that history navigation takes through our code. I would think it's in archive-filesystem-provider.ts, but no breakpoints are reached when Go Back is invoked.

aeisenberg commented 4 years ago

Based on some prompting by @p0, I did a deeper dive into this issue. There are currently three limitations that we know of regarding vscode FileSystemProviders.

  1. Code navigation locations are not recorded in history if the file is from a provider and the file was only opened in a preview editor. Navigation locations are removed if an editor for the file is closed https://github.com/microsoft/vscode/issues/108935
  2. Find in files command does not find text in files from providers. https://github.com/microsoft/vscode/issues/59921
  3. Open file command does not include files from providers. https://github.com/microsoft/vscode/issues/73524

As a further example, you can see the same limitations when using the sample MemFS file system provider.

To mitigate #1, we could always open archive files in non-preview mode when navigating from a results view. This would mitigate the problem, not fix it since if the editor is ever closed, we lose navigation history for it.