Skip to content

Commit c0cf4c4

Browse files
committed
Fix of loading solution on VS start.
1 parent 1e4e076 commit c0cf4c4

File tree

8 files changed

+277
-104
lines changed

8 files changed

+277
-104
lines changed

.vs/Nitra.sqlite

-2.6 MB
Binary file not shown.

Ide/NitraCommonVSIX/CodeCompletion/NitraCompletionCommandHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ bool StartSession()
102102
var snapshot = caretPos.Snapshot;
103103

104104

105-
var client = fileModel.Server.Client;
106105
if (session == null)
107106
_session = session = _provider.CompletionBroker.CreateCompletionSession(_wpfTextView, snapshot.CreateTrackingPoint(caretPos, PointTrackingMode.Positive), true);
108107
var triggerPoint = session.GetTriggerPoint(textBuffer);

Ide/NitraCommonVSIX/InteractiveHighlighting/InteractiveHighlightingTagger.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
using System.Windows.Shapes;
2727
using System.Diagnostics;
2828

29+
using Path = System.IO.Path;
30+
using Microsoft.VisualStudio.Shell;
31+
using Microsoft.VisualStudio.Shell.Interop;
32+
2933
namespace Nitra.VisualStudio.BraceMatching
3034
{
3135
public class InteractiveHighlightingTagger : ITagger<TextMarkerTag>
@@ -38,7 +42,9 @@ public class InteractiveHighlightingTagger : ITagger<TextMarkerTag>
3842
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
3943

4044
public InteractiveHighlightingTagger(IWpfTextView wpfTextView, ITextBuffer textBuffer)
41-
{
45+
{
46+
ThreadHelper.ThrowIfNotOnUIThread();
47+
4248
_wpfTextView = wpfTextView;
4349
_textBuffer = textBuffer;
4450
_caretPosOpt = null;
@@ -47,7 +53,13 @@ public InteractiveHighlightingTagger(IWpfTextView wpfTextView, ITextBuffer textB
4753
_wpfTextView.LayoutChanged += ViewLayoutChanged;
4854
_wpfTextView.Closed += _textView_Closed;
4955
((UIElement)_wpfTextView).IsVisibleChanged += Elem_IsVisibleChanged;
50-
56+
57+
if (NitraCommonVsPackage.Instance == null)
58+
{
59+
NitraCommonVsPackage.DeferUntilPackageInitialization(() => UpdateAtCaretPosition(_wpfTextView.Caret.Position));
60+
return;
61+
}
62+
5163
UpdateAtCaretPosition(_wpfTextView.Caret.Position);
5264
}
5365

@@ -96,6 +108,20 @@ TextViewModel GetTextViewModelOpt()
96108
if (_textBuffer.Properties.TryGetProperty<FileModel>(Constants.FileModelKey, out var fileModel))
97109
return VsUtils.GetOrCreateTextViewModel(_wpfTextView, fileModel);
98110

111+
var package = NitraCommonVsPackage.Instance;
112+
113+
if (package == null)
114+
return null;
115+
116+
var servers = package.Servers;
117+
118+
foreach (var server in servers)
119+
{
120+
textViewModel = package.TryCreateTextViewModel(_wpfTextView, server);
121+
if (textViewModel != null)
122+
return textViewModel;
123+
}
124+
99125
return null;
100126
}
101127

Ide/NitraCommonVSIX/Models/ServerModel.cs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.IO;
2424
using Microsoft.VisualStudio.Shell;
2525
using Nitra.VisualStudio.Utils;
26+
using Microsoft.VisualStudio.TextManager.Interop;
2627

2728
namespace Nitra.VisualStudio
2829
{
@@ -48,9 +49,9 @@ internal class ServerModel : IDisposable
4849

4950
public ServerModel(StringManager stringManager, Ide.Config config, IServiceProvider serviceProvider)
5051
{
51-
Contract.Requires(stringManager != null);
52-
Contract.Requires(config != null);
53-
Contract.Requires(serviceProvider != null);
52+
Debug.Assert(stringManager != null);
53+
Debug.Assert(config != null);
54+
Debug.Assert(serviceProvider != null);
5455

5556
ServiceProvider = serviceProvider;
5657

@@ -92,12 +93,7 @@ private static M.Config ConvertConfig(Ide.Config config)
9293
return msgConfig;
9394
}
9495

95-
FileModel GetFileModelOpt(FileId fileId)
96-
{
97-
if (_filIdToFileModelMap.TryGetValue(fileId, out var fileModel))
98-
return fileModel;
99-
return null;
100-
}
96+
FileModel GetFileModelOpt(FileId fileId) => _filIdToFileModelMap.TryGetValue(fileId, out var fileModel) ? fileModel : null;
10197

10298
internal void Add(FileModel fileModel)
10399
{
@@ -254,7 +250,7 @@ internal void ViewActivated(IWpfTextView wpfTextView, FileId id, IVsHierarchy hi
254250
fileModel.ViewActivated(textViewModel);
255251
}
256252

257-
void TryAddServerProperty(ITextBuffer textBuffer)
253+
internal void TryAddServerProperty(ITextBuffer textBuffer)
258254
{
259255
if (!textBuffer.Properties.ContainsProperty(Constants.ServerKey))
260256
textBuffer.Properties.AddProperty(Constants.ServerKey, this);

0 commit comments

Comments
 (0)