Enter-tainer / typst-preview

[DEPRECATED] Use tinymist instead
https://Enter-tainer.github.io/typst-preview/
MIT License
452 stars 21 forks source link

Preview icon disappears when clicking outside the document #262

Open supersurviveur opened 4 months ago

supersurviveur commented 4 months ago

Describe the bug

When I click outside the typst document (but keeping it open), the preview icon in the top right-hand corner disappears.

https://github.com/Enter-tainer/typst-preview/assets/54775010/a8a30463-3d27-4fc6-b3a7-c253a08b2947

To Reproduce

  1. Open a typst document
  2. Click outside the document (in the terminal or in the directory tree)

Expected behavior The preview icon should remain visible as long as the document is open, even if the user clicks outside the document.

Package/Software version:

Version : 1.87.0 (user setup)
Validation : 019f4d1419fbc8219a181fab7892ebccf7ee29a2
Date : 2024-02-27T23:41:44.469Z
Electron : 27.3.2
ElectronBuildId : 26836302
Chromium : 118.0.5993.159
Node.js : 18.17.1
V8 : 11.8.172.18-electron.0
Système d’exploitation : Windows_NT x64 10.0.22631

typst-preview extension version: v0.10.8

supersurviveur commented 4 months ago

Typst LSP seems to use "when": "editorLangId == typst" in the package.json file instead of "when": "resourceLangId == typst && editorTextFocus"

https://github.com/nvarner/typst-lsp/blob/master/editors/vscode/package.json#L314-L319

https://github.com/Enter-tainer/typst-preview/blob/64fc121fc104638934892f81b63536af8fa7e70d/addons/vscode/package.json#L94-L99

Myriad-Dreamin commented 4 months ago

But it is a bit meaningless if you are try to preview an extension console, since typst-preview will start a preview on the focused editor. Please correct me if there are reasonable use cases.

supersurviveur commented 4 months ago

Typst LSP seems to start rendering in the right place, even after clicking on the terminal. VSCode should be able to know that the document is loaded, even if the focus is in the terminal or the file tree, and i think it's possible to launch the preview on the document. This can be useful especially when opening a file, as the document doesn't take the focus.

Enter-tainer commented 4 months ago

https://github.com/nvarner/typst-lsp/blob/master/editors/vscode/src/extension.ts#L161

Enter-tainer commented 4 months ago

maybe we can try disable editorTextFocus and see if it works when editor is not focused. Like focusing on debug/output panel or terminal

Enter-tainer commented 4 months ago
image

It doesn't work for the output panel 🤔. But seems to work in terminal. perhaps we can add a check for that.

supersurviveur commented 4 months ago

It also doesn't work in the output panel for Typst LSP.