Skip to content

Commit 70a004d

Browse files
authored
Merge pull request #37 from Exafunction/exafunction/update
Bring to head of internal repo
2 parents 44f312d + 6170ef8 commit 70a004d

28 files changed

+387
-433
lines changed

CodeiumVS/CodeiumVSPackage.cs

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ namespace CodeiumVS;
2929
typeof(ChatToolWindow), MultiInstances = false, Style = VsDockStyle.Tabbed,
3030
Orientation = ToolWindowOrientation.Right,
3131
Window =
32-
"{3AE79031-E1BC-11D0-8F78-00A0C9110057}")] // default docking window, magic string for the
33-
// guid of
34-
// VSConstants.StandardToolWindows.SolutionExplorer
32+
"{3AE79031-E1BC-11D0-8F78-00A0C9110057}")] // default docking window, magic string for the
33+
// guid of
34+
// VSConstants.StandardToolWindows.SolutionExplorer
3535
public sealed class CodeiumVSPackage : ToolkitPackage
3636
{
3737
internal static CodeiumVSPackage? Instance { get; private set; }
@@ -264,24 +264,12 @@ public string GetLanguageServerPath()
264264
return Path.Combine(GetLanguageServerFolder(), binaryName);
265265
}
266266

267-
public string GetDatabaseDirectory()
268-
{
269-
return Path.Combine(GetAppDataPath(), "database");
270-
}
267+
public string GetDatabaseDirectory() { return Path.Combine(GetAppDataPath(), "database"); }
271268

272-
public string GetAPIKeyPath()
273-
{
274-
return Path.Combine(GetAppDataPath(), "codeium_api_key");
275-
}
269+
public string GetAPIKeyPath() { return Path.Combine(GetAppDataPath(), "codeium_api_key"); }
276270

277-
public bool IsSignedIn()
278-
{
279-
return LanguageServer.GetKey().Length > 0;
280-
}
281-
public bool HasEnterprise()
282-
{
283-
return SettingsPage.EnterpriseMode;
284-
}
271+
public bool IsSignedIn() { return LanguageServer.GetKey().Length > 0; }
272+
public bool HasEnterprise() { return SettingsPage.EnterpriseMode; }
285273

286274
internal void Log(string v)
287275
{

CodeiumVS/Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ internal class BaseCommandContextMenu<T> : BaseCommand<T>
7171
internal static bool is_visible = false;
7272

7373
protected static DocumentView? docView;
74-
protected static string text; // the selected text
74+
protected static string text; // the selected text
7575
protected static bool is_function = false;
7676
protected static int start_line, end_line;
7777
protected static int start_col, end_col;

CodeiumVS/InlineDiff/InlineDiffAdornment.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ public async Task CreateDiffAsync(int position, int length, string replacement)
129129
// for the OpenDocumentViaProject and IsPeekOnAdornment
130130
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
131131

132-
Assumes.True(
133-
position > 0 && length > 0 && (position + length) <= _hostView.TextSnapshot.Length,
134-
"InlineDiffAdornment.CreateDiff: Invalid position and length parameter");
132+
Assumes.True(position > 0 && length > 0 &&
133+
(position + length) <= _hostView.TextSnapshot.Length,
134+
"InlineDiffAdornment.CreateDiff: Invalid position and length parameter");
135135
Assumes.True(
136136
MefProvider.Instance.TextDocumentFactoryService.TryGetTextDocument(
137137
_hostView.TextDataModel.DocumentBuffer, out var textDocument),
@@ -518,18 +518,15 @@ private void Adornment_OnAccepted()
518518
}
519519
catch (Exception)
520520
{
521-
} // COMException
521+
} // COMException
522522

523523
DisposeDiff();
524524
}
525525

526526
/// <summary>
527527
/// The proposed diff has been rejected by the user.
528528
/// </summary>
529-
private void Adornment_OnRejected()
530-
{
531-
DisposeDiff();
532-
}
529+
private void Adornment_OnRejected() { DisposeDiff(); }
533530

534531
private void Adornment_OnSizeChanged(object sender, SizeChangedEventArgs e)
535532
{
@@ -677,7 +674,7 @@ private bool IsPeekOnAdornment()
677674
return true;
678675
}
679676

680-
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
677+
#pragma warning disable VSTHRD010 // Invoke single-threaded types on Main thread
681678

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

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

763760
[Export(typeof(ILineTransformSourceProvider))]

CodeiumVS/InlineDiff/InlineDiffControl.xaml.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,9 @@ private void LeftView_ViewportWidthChanged(object sender, EventArgs e)
5656
new GridLength(ContentBorder.Margin.Left + _inlineDiffView.LeftView.ViewportWidth);
5757
}
5858

59-
private void ButtonReject_Click(object sender, RoutedEventArgs e)
60-
{
61-
OnRejected?.Invoke();
62-
}
59+
private void ButtonReject_Click(object sender, RoutedEventArgs e) { OnRejected?.Invoke(); }
6360

64-
private void ButtonAccept_Click(object sender, RoutedEventArgs e)
65-
{
66-
OnAccepted?.Invoke();
67-
}
61+
private void ButtonAccept_Click(object sender, RoutedEventArgs e) { OnAccepted?.Invoke(); }
6862

6963
private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
7064
{

CodeiumVS/InlineDiff/InlineDiffView.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ private void OnContentTypeChanged(object sender, ContentTypeChangedEventArgs e)
4141
e.BeforeContentType, e.AfterContentType));
4242
}
4343

44-
public void Dispose()
45-
{
46-
DocumentBuffer.ContentTypeChanged -= OnContentTypeChanged;
47-
}
44+
public void Dispose() { DocumentBuffer.ContentTypeChanged -= OnContentTypeChanged; }
4845
}
4946

5047
private readonly IWpfTextView _hostView;
@@ -570,10 +567,7 @@ private void DiffView_OnLayoutChanged(object sender, TextViewLayoutChangedEventA
570567
/// </summary>
571568
/// <param name="sender"></param>
572569
/// <param name="e"></param>
573-
private void DiffView_OnViewportHeightChanged(object sender, EventArgs e)
574-
{
575-
RecalculateSize();
576-
}
570+
private void DiffView_OnViewportHeightChanged(object sender, EventArgs e) { RecalculateSize(); }
577571

578572
/// <summary>
579573
/// Show the "selected line highlight" (i.e. the grey rectangle surrounding the line) for this

CodeiumVS/LanguageServer/LanguageServer.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace CodeiumVS;
2424
public class LanguageServer
2525
{
2626
private string _languageServerURL;
27-
private string _languageServerVersion = "1.6.10";
27+
private string _languageServerVersion = "1.6.13";
2828

2929
private int _port = 0;
3030
private Process _process;
@@ -91,25 +91,16 @@ public void Dispose()
9191
Controller.Disconnect();
9292
}
9393

94-
public int GetPort()
95-
{
96-
return _port;
97-
}
98-
public string GetKey()
99-
{
100-
return _metadata.api_key;
101-
}
102-
public string GetVersion()
103-
{
104-
return _languageServerVersion;
105-
}
106-
public bool IsReady()
107-
{
108-
return _port != 0;
109-
}
94+
public int GetPort() { return _port; }
95+
public string GetKey() { return _metadata.api_key; }
96+
public string GetVersion() { return _languageServerVersion; }
97+
public bool IsReady() { return _port != 0; }
11098
public async Task WaitReadyAsync()
11199
{
112-
while (!IsReady()) { await Task.Delay(50); }
100+
while (!IsReady())
101+
{
102+
await Task.Delay(50);
103+
}
113104
}
114105

115106
// Get API key from the authentication token

CodeiumVS/LanguageServer/LanguageServerController.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,11 @@ public class LanguageServerController
1313
{
1414
readonly CodeiumVSPackage Package;
1515
public WebSocket? ws = null;
16-
public LanguageServerController()
17-
{
18-
Package = CodeiumVSPackage.Instance;
19-
}
16+
public LanguageServerController() { Package = CodeiumVSPackage.Instance; }
2017

2118
public async Task ConnectAsync()
2219
{
23-
#pragma warning disable VSTHRD103 // Call async methods when in an async method
20+
#pragma warning disable VSTHRD103 // Call async methods when in an async method
2421
void OnOpen(object sender, EventArgs e)
2522
{
2623
Package.Log($"Language Server Controller: Connected to {ws.Url}");
@@ -76,7 +73,7 @@ void OnError(object sender, WebSocketSharp.ErrorEventArgs error)
7673
Package.Log(
7774
$"Language Server Controller: Error '{error.Message}'; Exception: {error.Exception}");
7875
}
79-
#pragma warning restore VSTHRD103 // Call async methods when in an async method
76+
#pragma warning restore VSTHRD103 // Call async methods when in an async method
8077

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

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

9996
ITextSelection selection = docView.TextView.Selection;
10097

0 commit comments

Comments
 (0)