Skip to content

Commit

Permalink
Add Apply Diff feature
Browse files Browse the repository at this point in the history
  • Loading branch information
thedemons committed Dec 11, 2023
1 parent 5377559 commit 2cd801b
Show file tree
Hide file tree
Showing 8 changed files with 1,679 additions and 24 deletions.
11 changes: 10 additions & 1 deletion CodeiumVS/CodeiumVS.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<VSCommonIDEPath Condition="'$(VSCommonIDEPath)' == ''">$(MSBuildExtensionsPath32)\..\Common7\IDE</VSCommonIDEPath>
<LangVersion>latest</LangVersion>
<TargetFrameworkProfile />
</PropertyGroup>
Expand Down Expand Up @@ -46,6 +47,11 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="InlineDiff\InlineDiffAdornment.cs" />
<Compile Include="InlineDiff\InlineDiffControl.xaml.cs">
<DependentUpon>InlineDiffControl.xaml</DependentUpon>
</Compile>
<Compile Include="InlineDiff\InlineDiffView.cs" />
<Compile Include="LanguageServer\LanguageServerController.cs" />
<Compile Include="LanguageServer\LanguageServer.cs" />
<Compile Include="LanguageServer\Packets.cs" />
Expand Down Expand Up @@ -151,6 +157,9 @@
</PackageReference>
</ItemGroup>
<ItemGroup>
<Page Include="InlineDiff\InlineDiffControl.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Windows\ChatToolWindowControl.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
Expand Down
15 changes: 13 additions & 2 deletions CodeiumVS/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,19 @@ protected override void BeforeQueryStatus(EventArgs e)
is_visible = Command.Visible = ThreadHelper.JoinableTaskFactory.Run(async delegate
{
is_function = false;
docView = await VS.Documents.GetActiveDocumentViewAsync();
if (docView?.TextView == null) return false;

// any interactions with the `IVsTextView` should be done on the main thread
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

try
{
docView = await VS.Documents.GetActiveDocumentViewAsync();
if (docView?.TextView == null) return false;
}catch (Exception ex)
{
await CodeiumVSPackage.Instance.LogAsync($"BaseCommandContextMenu: Failed to get the active document view; Exception: {ex}");
return false;
}

languageInfo = Languages.Mapper.GetLanguage(docView);
ITextSelection selection = docView.TextView.Selection;
Expand Down
Loading

0 comments on commit 2cd801b

Please sign in to comment.