diff --git a/CodeiumVS/LanguageServer/LanguageServer.cs b/CodeiumVS/LanguageServer/LanguageServer.cs index f870c19..9a92a9e 100644 --- a/CodeiumVS/LanguageServer/LanguageServer.cs +++ b/CodeiumVS/LanguageServer/LanguageServer.cs @@ -26,11 +26,11 @@ namespace CodeiumVS; public class LanguageServer { private string _languageServerURL; - private string _languageServerVersion = "1.8.14"; + private string _languageServerVersion = "1.8.16"; private int _port = 0; private System.Diagnostics.Process _process; - private bool _intializedWorkspace = false; + private bool _initializedWorkspace = false; private readonly Metadata _metadata; private readonly HttpClient _httpClient; @@ -726,15 +726,28 @@ await _package.LogAsync( return default; } - private async Task IntializeTrackedWorkspaceAsync() + private async Task InitializeTrackedWorkspaceAsync() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - EnvDTE.DTE dte = (DTE)ServiceProvider.GlobalProvider.GetService(typeof(DTE)); - string solutionDir = System.IO.Path.GetDirectoryName(dte.Solution.FullName); - AddTrackedWorkspaceResponse response = await AddTrackedWorkspaceAsync(solutionDir); - if (response != null) + DTE dte = (DTE)ServiceProvider.GlobalProvider.GetService(typeof(DTE)); + foreach (EnvDTE.Project project in dte.Solution.Projects) { - _intializedWorkspace = true; + try + { + string projectDir = Path.GetDirectoryName(project.FullName); + if (!string.IsNullOrEmpty(projectDir)) + { + AddTrackedWorkspaceResponse response = await AddTrackedWorkspaceAsync(projectDir); + if (response != null) + { + _initializedWorkspace = true; + } + } + } + catch (Exception) + { + continue; + } } } @@ -751,9 +764,9 @@ public async Task?> int cursorPosition, string lineEnding, int tabSize, bool insertSpaces, CancellationToken token) { - if (!_intializedWorkspace) + if (!_initializedWorkspace) { - await IntializeTrackedWorkspaceAsync(); + await InitializeTrackedWorkspaceAsync(); } GetCompletionsRequest data = new() { metadata = GetMetadata(), @@ -786,9 +799,9 @@ public async Task AcceptCompletionAsync(string completionId) public async Task GetProcessesAsync() { - if (!_intializedWorkspace) + if (!_initializedWorkspace) { - await IntializeTrackedWorkspaceAsync(); + await InitializeTrackedWorkspaceAsync(); } return await RequestCommandAsync("GetProcesses", new {}); } diff --git a/CodeiumVS/SuggestionUI/InlineGreyTextTagger.cs b/CodeiumVS/SuggestionUI/InlineGreyTextTagger.cs index f278414..53082f4 100644 --- a/CodeiumVS/SuggestionUI/InlineGreyTextTagger.cs +++ b/CodeiumVS/SuggestionUI/InlineGreyTextTagger.cs @@ -64,6 +64,7 @@ public void MarkDirty() { try { + if (!view.TextViewLines.IsValid) { return; } var changeStart = view.TextViewLines.FirstVisibleLine.Start; var changeEnd = view.TextViewLines.LastVisibleLine.Start; diff --git a/CodeiumVS/SuggestionUI/SuggestionTagger.cs b/CodeiumVS/SuggestionUI/SuggestionTagger.cs index 6ca256c..ba9d2fc 100644 --- a/CodeiumVS/SuggestionUI/SuggestionTagger.cs +++ b/CodeiumVS/SuggestionUI/SuggestionTagger.cs @@ -499,24 +499,28 @@ public void ClearSuggestion() // triggers refresh of the screen void MarkDirty() { - GetTagger().MarkDirty(); - ITextSnapshot newSnapshot = buffer.CurrentSnapshot; - this.snapshot = newSnapshot; + try + { + GetTagger().MarkDirty(); + ITextSnapshot newSnapshot = buffer.CurrentSnapshot; + this.snapshot = newSnapshot; - if (view.TextViewLines == null) return; + if (view.TextViewLines == null) return; + if (!view.TextViewLines.IsValid) return; - var changeStart = view.TextViewLines.FirstVisibleLine.Start; - var changeEnd = view.TextViewLines.LastVisibleLine.Start; + var changeStart = view.TextViewLines.FirstVisibleLine.Start; + var changeEnd = view.TextViewLines.LastVisibleLine.Start; - var startLine = view.TextSnapshot.GetLineFromPosition(changeStart); - var endLine = view.TextSnapshot.GetLineFromPosition(changeEnd); + var startLine = view.TextSnapshot.GetLineFromPosition(changeStart); + var endLine = view.TextSnapshot.GetLineFromPosition(changeEnd); - var span = new SnapshotSpan(startLine.Start, endLine.EndIncludingLineBreak) - .TranslateTo(targetSnapshot: newSnapshot, SpanTrackingMode.EdgePositive); + var span = new SnapshotSpan(startLine.Start, endLine.EndIncludingLineBreak) + .TranslateTo(targetSnapshot: newSnapshot, SpanTrackingMode.EdgePositive); - // lines we are marking dirty - // currently all of them for simplicity - if (this.TagsChanged != null) { this.TagsChanged(this, new SnapshotSpanEventArgs(span)); } + // lines we are marking dirty + // currently all of them for simplicity + if (this.TagsChanged != null) { TagsChanged(this, new SnapshotSpanEventArgs(span)); } + } catch (Exception e) { Debug.Write(e); } } } diff --git a/CodeiumVS/SuggestionUI/TextViewListener.cs b/CodeiumVS/SuggestionUI/TextViewListener.cs index 9ddc5a9..d566e89 100644 --- a/CodeiumVS/SuggestionUI/TextViewListener.cs +++ b/CodeiumVS/SuggestionUI/TextViewListener.cs @@ -395,7 +395,17 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv // gets lsp completions on added character or deletions if (!typedChar.Equals(char.MinValue) || commandID == (uint)VSConstants.VSStd2KCmdID.RETURN || regenerateSuggestion) { - _ = Task.Run(() => GetCompletion()); + _ = Task.Run(() => + { + try + { + GetCompletion(); + } + catch (Exception e) + { + Debug.Write(e); + } + }); handled = true; } else if (commandID == (uint)VSConstants.VSStd2KCmdID.BACKSPACE || @@ -403,7 +413,17 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv { ClearSuggestion(); - _ = Task.Run(() => GetCompletion()); + _ = Task.Run(() => + { + try + { + GetCompletion(); + } + catch (Exception e) + { + Debug.Write(e); + } + }); handled = true; } diff --git a/CodeiumVS/source.extension.cs b/CodeiumVS/source.extension.cs index 8755217..3527924 100644 --- a/CodeiumVS/source.extension.cs +++ b/CodeiumVS/source.extension.cs @@ -11,7 +11,7 @@ internal sealed partial class Vsix public const string Name = "Codeium"; public const string Description = @"The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster."; public const string Language = "en-US"; - public const string Version = "1.8.14"; + public const string Version = "1.8.17"; public const string Author = "Codeium"; public const string Tags = ""; } diff --git a/CodeiumVS/source.extension.vsixmanifest b/CodeiumVS/source.extension.vsixmanifest index f97d28c..b53e41f 100644 --- a/CodeiumVS/source.extension.vsixmanifest +++ b/CodeiumVS/source.extension.vsixmanifest @@ -1,7 +1,7 @@ - + Codeium The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster. https://www.codeium.com