snuup / FSharp-File-Structure-for-Visual-Studio

Visual Studio Extension for VS 2019 that provides a File Structure Toolwindow for F#
22 stars 3 forks source link

File structure tab looses name/contents when no F# file is selected. It is not synchronized with active window #2

Open kodfodrasz opened 3 years ago

kodfodrasz commented 3 years ago

Dear @snuup!

I really like your extension, it is really handy is fills a gap! However, there are two minor annoyances I have experienced, which would improve a lot on my user experience, should they be solved.

The problems

1. tool window label is missing sometimes

The problem is when VS starts up/a project loads, and the docked tool window has no text title whatsoever:

kép

Now when I open a file, and click in its editor window, it is cool: kép

2. tool window contents are not updated on active editor tab/window change

A related problem is: the window contents are not updated until I click in an editor, selecting the editor tab is not enough:

kép

Here you can see that the active editor shows a different file than the file structure window

Suggested solutions

  1. I think if the tool window would always have the label "F# Sile Structure".
  2. The window/tab activation should also be hooked for file structure update events.

Summary

I don't know much about VS plugin development, how difficult it may be to implement these (especially the second point), but for me personally these would boost the tools usability greatly, as it would speed up navigation, and save some confusion on some occasions.

Thank you for your great extension!

Greetings, @kodfodrasz

kodfodrasz commented 3 years ago

I must add that now I can see the window contents updated on open editor window change, so reported problem 2. is not always happening. Will try to note steps when problem happens again.

snuup commented 3 years ago

Thank you for your detailed and constructive report @kodfodrasz . The bugs you mention occur on my machine too.

The Toolwindow label issue should be fixable quite easily,

The sync problem is a bit more problematic: To avoid costly processing, I filter updating the f# Toolwindow. I assume that this filtering is the root of the problem (Package.cs) :

  if (this.GetToolWindow().Control.IsVisible)
  // avoid costly f# syntax processing when window is not visible / used.
  {
      this.UpdateFileStructure(td, doc);
  }

The workaround to get the toolwindow into sync is then to open editors (files, tabs) while the toolwindow is visible. Maybe the check above should be removed, but on the other hand then the toolwindow is updated while it is unused.

I do not have the time at the moment to work on that, I will keep this issue open.

kodfodrasz commented 3 years ago

Maybe if the active document reference would be stored if the control is not visible, and the processing would be done only on Activation. I'll also try to check it if I'll have some time to dig into it, this pointer you gave is a great clue to get started.

snuup commented 3 years ago

that makes very good sense!

i you are new to VS extension development:

debug: If you start the project in debug mode, it opens an isolated VS instance with its own settings and configuration, called the "Exp" instance and you can use VS to debug the other VS instance.

release: build it and you get a new vsix installable package.