|
6 | 6 | * You may obtain a copy of the License at |
7 | 7 | * |
8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | | - * |
| 9 | + * |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
@@ -231,7 +231,7 @@ protected async override System.Threading.Tasks.Task InitializeAsync(Cancellatio |
231 | 231 | _menuItemSetActiveToken = new MenuCommand(MenuItemCallback, setActiveTokenCommandID); |
232 | 232 | _menuItemCreateCdb = new MenuCommand(MenuItemCallback, createCdbID); |
233 | 233 | _menuItemOpenLogDir = new MenuCommand(MenuItemCallback, openLogDirID); |
234 | | - |
| 234 | + |
235 | 235 | _menuItemSetActiveToken.Enabled = false; |
236 | 236 | _menuItemCreateCdb.Enabled = false; |
237 | 237 | _menuItemOpenLogDir.Enabled = true; |
@@ -457,13 +457,22 @@ private void OnNetworkReadCallback(string message) |
457 | 457 | Logging.Logging.LogInfo("Trying to set cursor position to line " + cursorPosition.LineNumber + ", column " + cursorPosition.ColumnNumber + " in file \"" + cursorPosition.FilePath + "\""); |
458 | 458 |
|
459 | 459 | cursorPosition.ColumnNumber += 1; // VS counts columns starting at 1, sourcetrail starts at 0 |
460 | | - DTE dte = (DTE)GetService(typeof(DTE)); |
461 | | - if (Utility.FileUtility.OpenSourceFile(dte, cursorPosition.FilePath)) |
462 | | - { |
463 | | - Utility.FileUtility.GoToLine(dte, cursorPosition.LineNumber, cursorPosition.ColumnNumber); |
464 | 460 |
|
465 | | - Utility.SystemUtility.GetWindowFocus(); |
466 | | - } |
| 461 | + ThreadHelper.JoinableTaskFactory.Run( |
| 462 | + async delegate |
| 463 | + { |
| 464 | + // Switch to main thread |
| 465 | + await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); |
| 466 | + |
| 467 | + DTE dte = (DTE)GetService(typeof(DTE)); |
| 468 | + if (Utility.FileUtility.OpenSourceFile(dte, cursorPosition.FilePath)) |
| 469 | + { |
| 470 | + Utility.FileUtility.GoToLine(dte, cursorPosition.LineNumber, cursorPosition.ColumnNumber); |
| 471 | + |
| 472 | + Utility.SystemUtility.GetWindowFocus(); |
| 473 | + } |
| 474 | + } |
| 475 | + ); |
467 | 476 | } |
468 | 477 | } |
469 | 478 | else if(messageType == Utility.NetworkProtocolUtility.MESSAGE_TYPE.CREATE_CDB) |
@@ -576,7 +585,7 @@ private void CreateCompilationDatabase(DTE dte) |
576 | 585 |
|
577 | 586 | window.UpdateGUI(); |
578 | 587 | window._onCreateProject = OnCreateProject; |
579 | | - |
| 588 | + |
580 | 589 | window.ShowDialog(); |
581 | 590 | } |
582 | 591 | } |
|
0 commit comments