wmjordan / Codist

A visual studio extension which enhances syntax highlighting, quick info (tooltip), navigation bar, scrollbar, display quality, and brings smart tool bar with code refactoring to code editor.
https://marketplace.visualstudio.com/items?itemName=wmj.Codist
GNU General Public License v3.0
317 stars 29 forks source link

Syntax styles not saved/restored #297

Closed nurbles closed 1 year ago

nurbles commented 1 year ago

With VS2022 17.7.1 and Codist 7.7.1.9318 I need to import my (thankfully) previously exported syntax styles every morning when I first start VS. When VS starts, the syntax styles are set to "something else" that is not my settings.

My morning process is now:

  1. Start VS2022.
  2. Load my project and notice the syntax styles are wrong.
  3. Open the 'Customize Codist Syntax Highlight...' dialog.
  4. Import my previously exported settings.
  5. Click the SAVE button to close the dialog.
  6. Work all day with my preferred syntax styles.
  7. Shutdown VS2022 and computer.
  8. Restart at step 1 tomorrow.

Since I can only see the effect, I do not know if the styles are not saved or if they are not loaded. I'm going to attach my exported styles and my Codist config file, in case they are useful. Oh, VS2022 was still running when I captured the first config file.

I ran a simple test by monitoring the config file when VS was closed and the config file did not change at that time. When I restarted VS and loaded by project, the colors were wrong again (and the config file still had not changed) so I imported my settings again and the config file changed to what is in the second copy.

Codist.zip Config.zip Config2.zip

Also, FWIW, I have not seen this issue with VS2019 16.11.29 and Codist 7.7.1.9318.

wmjordan commented 1 year ago

I also noticed that when I was testing. VS 17.7.1 has gotten some weirdness in its syntax highlight priorities.

Here's another user's report: #295

I will check it with your configuration files and reply later.

wmjordan commented 1 year ago

Config.zip and Config2.zip are byte-to-byte identical. I reproduced this issue with the sample config files.

If you don't set the color of identifier, it seems that the color will be right. Somehow the styles got corrupted with the setting of identifier. I currently have no idea how to fix it.

nurbles commented 1 year ago

Thanks, your work-around appears to be successful! I have no doubt that you will figure out what's happening sooner or later -- your track record seems pretty good from where I'm sitting! :-) Since there's a work-around, there's seems to be no rush to fix this unless you find it is related to and/or affecting something else.

wmjordan commented 1 year ago

Thank you for your feedback. How are you doing recently?

I do have doubt that I would figure it out. No API allows us to ultimately arrange how styles are mixed together. And the implementation could change, as you have seen across VS versions. The highlight within VS is a mysteriously mysterious mystery. I've been spending uncountable hours on this during these years--somewhat got tired of it. I will get my hand on some other unimplemented features when I have time.

nurbles commented 1 year ago

I'm sorry to say that, after more time working in VS2022 this week, I have not been able to get the work-around to change the behavior. Even after resetting the identifier styles I still need to import my previously exported styles almost every time I start VS2022. The almost is strange -- every once in a while, if I exit VS2022 and realize I'd forgotten something a few minutes later and restart it then all the colors/styles are correct. However, nine (or more) times out of ten that is not the case and it is never the case the first time I start in the morning.

It is "livable" since everything seems to be fine once the import is complete. Hmmm... maybe I can learn about macros and find a way to automate importing the styles when a project is loaded... I need to see if that is possible. :-)

So I'm saying don't waste time on this (unless, of course, you're in the mood for frustration! ) VS2022 17.7.3 Codist 7.7.2.9322 (from the VS Marketplace)

wmjordan commented 1 year ago

The cause of this issue is unclear. I once met with it after turning on the "faster project load". However, it no longer appeared after that, and the failure of highlighting had never occurred while I was debugging Codist. However, this issue really causes some troubles. At least 4 users (including you and I) have been bothered by it up to now. I will try to work on it once I have an idea about what is going on.

Decimation commented 1 year ago

I am encountering the same issue after updating to the latest release. Visual Studio crashed before I started encountering the problem, and Visual Studio reported Codist as the cause.

wmjordan commented 1 year ago

Visual Studio crashed before I started encountering the problem

Please check out the Windows event viewer and post the stack trace here.

Decimation commented 1 year ago
Application: devenv.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at Codist.Display.EditorWindowDisplayOptimizer.TextViewLoaded(System.Object, System.EventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean)
   at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(System.Windows.DependencyObject, System.Windows.RoutedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(System.Object)
   at MS.Internal.LoadedOrUnloadedOperation.DoWork()
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(System.Object)
   at System.Windows.Media.MediaContext.RenderMessageHandler(System.Object)
   at System.Windows.Interop.HwndTarget.OnResize()
   at System.Windows.Interop.HwndTarget.HandleMessage(MS.Internal.Interop.WindowMessage, IntPtr, IntPtr)
   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.HwndSubclass.DefWndProcWrapper(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.CallWindowProc(IntPtr, IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
wmjordan commented 1 year ago

Merged into #303.