Skip to content

Commit

Permalink
Notifications about changes to the selected text
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Gołębiowski committed Aug 9, 2024
1 parent fc0365a commit 3b95532
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 276 deletions.
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

0 comments on commit 3b95532

Please sign in to comment.