Skip to content
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
26 changes: 7 additions & 19 deletions CodeiumVS/CodeiumVSPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ namespace CodeiumVS;
typeof(ChatToolWindow), MultiInstances = false, Style = VsDockStyle.Tabbed,
Orientation = ToolWindowOrientation.Right,
Window =
"{3AE79031-E1BC-11D0-8F78-00A0C9110057}")] // default docking window, magic string for the
// guid of
// VSConstants.StandardToolWindows.SolutionExplorer
"{3AE79031-E1BC-11D0-8F78-00A0C9110057}")] // default docking window, magic string for the
// guid of
// VSConstants.StandardToolWindows.SolutionExplorer
public sealed class CodeiumVSPackage : ToolkitPackage
{
internal static CodeiumVSPackage? Instance { get; private set; }
Expand Down Expand Up @@ -264,24 +264,12 @@ public string GetLanguageServerPath()
return Path.Combine(GetLanguageServerFolder(), binaryName);
}

public string GetDatabaseDirectory()
{
return Path.Combine(GetAppDataPath(), "database");
}
public string GetDatabaseDirectory() { return Path.Combine(GetAppDataPath(), "database"); }

public string GetAPIKeyPath()
{
return Path.Combine(GetAppDataPath(), "codeium_api_key");
}
public string GetAPIKeyPath() { return Path.Combine(GetAppDataPath(), "codeium_api_key"); }

public bool IsSignedIn()
{
return LanguageServer.GetKey().Length > 0;
}
public bool HasEnterprise()
{
return SettingsPage.EnterpriseMode;
}
public bool IsSignedIn() { return LanguageServer.GetKey().Length > 0; }
public bool HasEnterprise() { return SettingsPage.EnterpriseMode; }

internal void Log(string v)
{
Expand Down
2 changes: 1 addition & 1 deletion CodeiumVS/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ internal class BaseCommandContextMenu<T> : BaseCommand<T>
internal static bool is_visible = false;

protected static DocumentView? docView;
protected static string text; // the selected text
protected static string text; // the selected text
protected static bool is_function = false;
protected static int start_line, end_line;
protected static int start_col, end_col;
Expand Down
17 changes: 7 additions & 10 deletions CodeiumVS/InlineDiff/InlineDiffAdornment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ public async Task CreateDiffAsync(int position, int length, string replacement)
// for the OpenDocumentViaProject and IsPeekOnAdornment
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

Assumes.True(
position > 0 && length > 0 && (position + length) <= _hostView.TextSnapshot.Length,
"InlineDiffAdornment.CreateDiff: Invalid position and length parameter");
Assumes.True(position > 0 && length > 0 &&
(position + length) <= _hostView.TextSnapshot.Length,
"InlineDiffAdornment.CreateDiff: Invalid position and length parameter");
Assumes.True(
MefProvider.Instance.TextDocumentFactoryService.TryGetTextDocument(
_hostView.TextDataModel.DocumentBuffer, out var textDocument),
Expand Down Expand Up @@ -518,18 +518,15 @@ private void Adornment_OnAccepted()
}
catch (Exception)
{
} // COMException
} // COMException

DisposeDiff();
}

/// <summary>
/// The proposed diff has been rejected by the user.
/// </summary>
private void Adornment_OnRejected()
{
DisposeDiff();
}
private void Adornment_OnRejected() { DisposeDiff(); }

private void Adornment_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
Expand Down Expand Up @@ -677,7 +674,7 @@ private bool IsPeekOnAdornment()
return true;
}

#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread

// By default, the adornments doesn't received the keyboard inputs it deserved, sadly.
// We have to "hook" the host view commands filter list and check if our adornments
Expand Down Expand Up @@ -757,7 +754,7 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv

return _commandTarget.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);
}
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
#pragma warning restore VSTHRD010 // Invoke single-threaded types on Main thread
}

[Export(typeof(ILineTransformSourceProvider))]
Expand Down
10 changes: 2 additions & 8 deletions CodeiumVS/InlineDiff/InlineDiffControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,9 @@ private void LeftView_ViewportWidthChanged(object sender, EventArgs e)
new GridLength(ContentBorder.Margin.Left + _inlineDiffView.LeftView.ViewportWidth);
}

private void ButtonReject_Click(object sender, RoutedEventArgs e)
{
OnRejected?.Invoke();
}
private void ButtonReject_Click(object sender, RoutedEventArgs e) { OnRejected?.Invoke(); }

private void ButtonAccept_Click(object sender, RoutedEventArgs e)
{
OnAccepted?.Invoke();
}
private void ButtonAccept_Click(object sender, RoutedEventArgs e) { OnAccepted?.Invoke(); }

private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
{
Expand Down
10 changes: 2 additions & 8 deletions CodeiumVS/InlineDiff/InlineDiffView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ private void OnContentTypeChanged(object sender, ContentTypeChangedEventArgs e)
e.BeforeContentType, e.AfterContentType));
}

public void Dispose()
{
DocumentBuffer.ContentTypeChanged -= OnContentTypeChanged;
}
public void Dispose() { DocumentBuffer.ContentTypeChanged -= OnContentTypeChanged; }
}

private readonly IWpfTextView _hostView;
Expand Down Expand Up @@ -570,10 +567,7 @@ private void DiffView_OnLayoutChanged(object sender, TextViewLayoutChangedEventA
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DiffView_OnViewportHeightChanged(object sender, EventArgs e)
{
RecalculateSize();
}
private void DiffView_OnViewportHeightChanged(object sender, EventArgs e) { RecalculateSize(); }

/// <summary>
/// Show the "selected line highlight" (i.e. the grey rectangle surrounding the line) for this
Expand Down
27 changes: 9 additions & 18 deletions CodeiumVS/LanguageServer/LanguageServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace CodeiumVS;
public class LanguageServer
{
private string _languageServerURL;
private string _languageServerVersion = "1.6.10";
private string _languageServerVersion = "1.6.13";

private int _port = 0;
private Process _process;
Expand Down Expand Up @@ -91,25 +91,16 @@ public void Dispose()
Controller.Disconnect();
}

public int GetPort()
{
return _port;
}
public string GetKey()
{
return _metadata.api_key;
}
public string GetVersion()
{
return _languageServerVersion;
}
public bool IsReady()
{
return _port != 0;
}
public int GetPort() { return _port; }
public string GetKey() { return _metadata.api_key; }
public string GetVersion() { return _languageServerVersion; }
public bool IsReady() { return _port != 0; }
public async Task WaitReadyAsync()
{
while (!IsReady()) { await Task.Delay(50); }
while (!IsReady())
{
await Task.Delay(50);
}
}

// Get API key from the authentication token
Expand Down
11 changes: 4 additions & 7 deletions CodeiumVS/LanguageServer/LanguageServerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ public class LanguageServerController
{
readonly CodeiumVSPackage Package;
public WebSocket? ws = null;
public LanguageServerController()
{
Package = CodeiumVSPackage.Instance;
}
public LanguageServerController() { Package = CodeiumVSPackage.Instance; }

public async Task ConnectAsync()
{
#pragma warning disable VSTHRD103 // Call async methods when in an async method
#pragma warning disable VSTHRD103 // Call async methods when in an async method
void OnOpen(object sender, EventArgs e)
{
Package.Log($"Language Server Controller: Connected to {ws.Url}");
Expand Down Expand Up @@ -76,7 +73,7 @@ void OnError(object sender, WebSocketSharp.ErrorEventArgs error)
Package.Log(
$"Language Server Controller: Error '{error.Message}'; Exception: {error.Exception}");
}
#pragma warning restore VSTHRD103 // Call async methods when in an async method
#pragma warning restore VSTHRD103 // Call async methods when in an async method

GetProcessesResponse? result = await Package.LanguageServer.GetProcessesAsync();

Expand All @@ -94,7 +91,7 @@ private void InsertText(string text)
.RunAsync(async delegate {
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync();
if (docView?.TextView == null) return; // not a text window
if (docView?.TextView == null) return; // not a text window

ITextSelection selection = docView.TextView.Selection;

Expand Down
Loading