Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version to 1.8.17. Call AddTrackedWorkspace per project #66

Merged
merged 3 commits into from
Mar 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 25 additions & 12 deletions CodeiumVS/LanguageServer/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
}

Expand All @@ -751,9 +764,9 @@ public async Task<IList<CompletionItem>?>
int cursorPosition, string lineEnding, int tabSize, bool insertSpaces,
CancellationToken token)
{
if (!_intializedWorkspace)
if (!_initializedWorkspace)
{
await IntializeTrackedWorkspaceAsync();
await InitializeTrackedWorkspaceAsync();
}
GetCompletionsRequest data =
new() { metadata = GetMetadata(),
Expand Down Expand Up @@ -786,9 +799,9 @@ public async Task AcceptCompletionAsync(string completionId)

public async Task<GetProcessesResponse?> GetProcessesAsync()
{
if (!_intializedWorkspace)
if (!_initializedWorkspace)
{
await IntializeTrackedWorkspaceAsync();
await InitializeTrackedWorkspaceAsync();
}
return await RequestCommandAsync<GetProcessesResponse>("GetProcesses", new {});
}
Expand Down
1 change: 1 addition & 0 deletions CodeiumVS/SuggestionUI/InlineGreyTextTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 17 additions & 13 deletions CodeiumVS/SuggestionUI/SuggestionTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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); }
}
}

Expand Down
24 changes: 22 additions & 2 deletions CodeiumVS/SuggestionUI/TextViewListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,35 @@ 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 ||
commandID == (uint)VSConstants.VSStd2KCmdID.DELETE)
{
ClearSuggestion();

_ = Task.Run(() => GetCompletion());
_ = Task.Run(() =>
{
try
{
GetCompletion();
}
catch (Exception e)
{
Debug.Write(e);
}
});
handled = true;
}

Expand Down
2 changes: 1 addition & 1 deletion CodeiumVS/source.extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
}
Expand Down
2 changes: 1 addition & 1 deletion CodeiumVS/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Codeium.VisualStudio" Version="1.8.14" Language="en-US" Publisher="Codeium" />
<Identity Id="Codeium.VisualStudio" Version="1.8.17" Language="en-US" Publisher="Codeium" />
<DisplayName>Codeium</DisplayName>
<Description xml:space="preserve">The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster.</Description>
<MoreInfo>https://www.codeium.com</MoreInfo>
Expand Down
Loading