madskristensen/WebEssentials2013 — pull request #1324 by nycdotnet (2014-07-17 17:35:50+00:00)
Title: Fix for "rescroll on save" issue for TypeScript preview pane

In Web Essentials v2.2.6.1, the TypeScript JS preview pane always scrolls back to the first line when the TypeScript file is saved. This presents a significant usability issue for TypeScript files taller than one screen since there is no "scroll sync" feature yet.

The root cause appears to have been related to a cross-thread ownership issue, specifically "The calling thread cannot access this object because a different thread owns it."

This pull request fixes the issue by checking the access to the PreviewTextHost.HostControl before attempting to update anything. If the current thread has access, it updates everything as before. If the current thread does not have access, it simply uses the Dispatcher to invoke the update.

I tested this for TypeScript, CoffeeScript, and LESS and all seemed to work correctly as before.