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

Notifications about changes to selected text #31

Merged
merged 1 commit into from
Aug 9, 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
5 changes: 3 additions & 2 deletions src/Cody.Core/DocumentSync/DocumentSyncCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Nerdbank.Streams.MultiplexingStream;

namespace Cody.Core.DocumentSync
{
Expand All @@ -29,7 +30,7 @@ private string ToUri(string path)

public void OnChanged(string fullPath, DocumentRange visibleRange, DocumentRange selection, IEnumerable<DocumentChange> changes)
{
logger.Debug($"Sending didChange() for '{fullPath}' changes: {string.Join("|", changes.Select(x => x.Text))}");
logger.Debug($"Sending didChange() for '{fullPath}', s:{selection}, v:{visibleRange}, c:{string.Join("", changes)}");

Range vRange = null;
if (visibleRange != null)
Expand Down Expand Up @@ -110,7 +111,7 @@ public void OnFocus(string fullPath)

public void OnOpened(string fullPath, string content, DocumentRange visibleRange, DocumentRange selection)
{
logger.Debug($"Sending DidOpen() for '{fullPath}'");
logger.Debug($"Sending DidOpen() for '{fullPath}', s:{selection}, v:{visibleRange}");

Range vRange = null;
if (visibleRange != null)
Expand Down
6 changes: 6 additions & 0 deletions src/Cody.Core/DocumentSync/IDocumentSyncActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@ public class DocumentPosition
public int Line { get; set; }

public int Column { get; set; }

public override string ToString() => $"({Line},{Column})";
}

public class DocumentRange
{
public DocumentPosition Start { get; set; }

public DocumentPosition End { get; set; }

public override string ToString() => $"{Start}-{End}";
}

public class DocumentChange
{
public string Text { get; set; }
public DocumentRange Range { get; set; }

public override string ToString() => $"['{Text}':{Range}]";
}
}
2 changes: 1 addition & 1 deletion src/Cody.VisualStudio/Cody.VisualStudio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CodyPackage.cs" />
<Compile Include="Properties\AssemblyVersion.cs" />
<Compile Include="Services\DocumentsSyncManager.cs" />
<Compile Include="Services\DocumentsSyncService.cs" />
<Compile Include="Services\OptionsPage.cs">
<SubType>Component</SubType>
</Compile>
Expand Down
6 changes: 3 additions & 3 deletions src/Cody.VisualStudio/CodyPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public sealed class CodyPackage : AsyncPackage
public IVsEditorAdaptersFactoryService VsEditorAdaptersFactoryService;
public IVsUIShell VsUIShell;
public IAgentClientFactory AgentClientFactory;
public DocumentsSyncManager DocumentsSyncManager;
public DocumentsSyncService DocumentsSyncService;

protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
Expand Down Expand Up @@ -189,8 +189,8 @@ private async Task InitializeAgent()
.ContinueWith(x =>
{
var documentSyncCallback = new DocumentSyncCallback(AgentClientFactory, Logger);
DocumentsSyncManager = new DocumentsSyncManager(VsUIShell, documentSyncCallback, VsEditorAdaptersFactoryService);
DocumentsSyncManager.Initialize();
DocumentsSyncService = new DocumentsSyncService(VsUIShell, documentSyncCallback, VsEditorAdaptersFactoryService);
DocumentsSyncService.Initialize();
})
.ContinueWith(t =>
{
Expand Down
234 changes: 0 additions & 234 deletions src/Cody.VisualStudio/Services/DocumentsSyncManager.cs

This file was deleted.

Loading
Loading