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

Fix for missing selection data #193

Merged
merged 2 commits into from
Jan 6, 2025
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
79 changes: 46 additions & 33 deletions src/Cody.Core/DocumentSync/DocumentSyncCallback.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,47 +104,60 @@ public void OnFocus(string fullPath)

public void OnOpened(string fullPath, string content, DocumentRange visibleRange, DocumentRange selection)
{
trace.TraceEvent("DidOpen", "sel:{0}, vr:{1}, path:{2}", selection, visibleRange, fullPath);

Range vRange = null;
if (visibleRange != null)
try
{
vRange = new Range
trace.TraceEvent("DidOpen", "sel:{0}, vr:{1}, path:{2}", selection, visibleRange, fullPath);

Range vRange = null;
if (visibleRange != null)
{
Start = new Position
vRange = new Range
{
Line = visibleRange.Start.Line,
Character = visibleRange.Start.Column
},
End = new Position
{
Line = visibleRange.End.Line,
Character = visibleRange.End.Column
}
};
}
Start = new Position
{
Line = visibleRange.Start.Line,
Character = visibleRange.Start.Column
},
End = new Position
{
Line = visibleRange.End.Line,
Character = visibleRange.End.Column
}
};
}

var docState = new ProtocolTextDocument
{
Uri = fullPath.ToUri(),
Content = content.ConvertLineBreaks("\n"),
VisibleRange = vRange,
Selection = new Range
Range selRange = null;
if (selection != null)
{
Start = new Position
selRange = new Range
{
Line = selection.Start.Line,
Character = selection.Start.Column
},
End = new Position
{
Line = selection.End.Line,
Character = selection.End.Column
}
Start = new Position
{
Line = selection.Start.Line,
Character = selection.Start.Column
},
End = new Position
{
Line = selection.End.Line,
Character = selection.End.Column
}
};
}
};

agentService.DidOpen(docState);
var docState = new ProtocolTextDocument
{
Uri = fullPath.ToUri(),
Content = content.ConvertLineBreaks("\n"),
VisibleRange = vRange,
Selection = selRange
};

agentService.DidOpen(docState);
}
catch (Exception ex)
{
logger.Error("Exception in OnOpened()", ex);
}
}

public void OnSaved(string fullPath)
Expand Down
2 changes: 1 addition & 1 deletion src/Cody.VisualStudio.Tests/ChatLoggedBasicTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public ChatLoggedBasicTests(ITestOutputHelper output) : base(output)
});
}

[VsFact(Version = VsVersion.VS2022)]
[VsFact(Version = VsVersion.VS2022, Skip = "Unstable")]
public async Task Solution_Name_Is_Added_To_Chat_Input()
{
// given
Expand Down
2 changes: 1 addition & 1 deletion src/Cody.VisualStudio.Tests/ChatNotLoggedStateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ await NotInLoggedState(async () =>

}

[VsFact(Version = VsVersion.VS2022)]
[VsFact(Version = VsVersion.VS2022, Skip = "Unstable")]
public async Task Cody_Enterprise_Section_Is_Present()
{
// given
Expand Down
4 changes: 2 additions & 2 deletions src/Cody.VisualStudio/Services/DocumentsSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public void Initialize()
var content = rdt.GetRunningDocumentContents(docCookie);
var textView = GetTextView(frame);
var visibleRange = GetVisibleRange(textView);
var docRange = GetDocumentSelection(textView);
var selection = GetDocumentSelection(textView);

documentActions.OnOpened(path, content, visibleRange, docRange);
documentActions.OnOpened(path, content, visibleRange, selection);
}
catch (Exception ex)
{
Expand Down
Loading