Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
494 stars 25 forks source link

Clicking on preview opens a new window when working with multiple typst files #534

Open ziiirozone opened 4 weeks ago

ziiirozone commented 4 weeks ago

Describe the bug Hello ! I'm currently working with vs code on two different typst files, which I both have previews of. For the sake of explainations I'll number them file 1, file 2 & preview 1, preview 2. When I interact with file 1 and click on a word in preview 1 everything works as expected, but when I click on a word in preview 2, a new window with file 2 opens with the cursor on the word I clicked on. I now have 2 windows with file 2 open. When I double click on a word of preview 2 it seems to remember the first instance of file 2 and goes back to it. This makes working on multiple typst files quite difficult.

VSCode version :

Version: 1.92.1 (user setup)
Commit: eaa41d57266683296de7d118f574d0c2652e1fc4
Date: 2024-08-07T20:16:39.455Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

tinymist version 0.11.19

Myriad-Dreamin commented 3 weeks ago

The opening to new window function usually works well when the layout simply looks like following:

image

But thing goes worse rapidly in other layouts, and we don't know how many layouts we should adapt to. I believe this is likely a fun twist to tune for previewing, and it is not quite related to tinymist's core function. The current algorithm is used here:

https://github.com/Myriad-Dreamin/tinymist/blob/68911d91cbaea2e9fb91f33df3d803b5b433ee41/editors/vscode/src/preview.ts#L684

https://github.com/Myriad-Dreamin/tinymist/blob/68911d91cbaea2e9fb91f33df3d803b5b433ee41/editors/vscode/src/util.ts#L24-L33

ziiirozone commented 3 weeks ago

I have no knowledge on how vs. code works or even how to program in typescript, but wouldn't it be possible to loop over each editor until one is found with a title matching that of the preview ?

Myriad-Dreamin commented 3 weeks ago

but wouldn't it be possible to loop over each editor until one is found with a title matching that of the preview ?

May be.

memeplex commented 3 weeks ago

I'm seeing this quite frequently too. I'm trying to find some recipe in order to reproduce it in a more reliable fashion, still to no avail. By now I do can say that:

memeplex commented 3 weeks ago

Ok, here's a reliable way to make it happen:

  1. Create a project
  2. Add a simple test.typ file with some content
  3. Open the preview
  4. Initalize git for the project
  5. From source control open the diff tab for the file
  6. Click the preview

At that point you should have:

image