Skip to content

Commit

Permalink
Bump Fantomas.Client from 0.4.0 to 0.9.0 in /src/FantomasVs.VS2022 (#51)
Browse files Browse the repository at this point in the history
* Bump Fantomas.Client from 0.4.0 to 0.9.0 in /src/FantomasVs.VS2022
* Support breaking API change

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Asti <[email protected]>
  • Loading branch information
dependabot[bot] and deviousasti authored Apr 9, 2023
1 parent 5b50de4 commit c9d60c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/FantomasVs.Shared/FantomasHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ public async Task<bool> FormatAsync(SnapshotSpan vspan, EditorCommandArgs args,
FormatKind.IsolatedSelection => vspan.GetText(),
_ => throw new NotSupportedException($"Operation {kind} is not supported")
};

var response = await (kind switch
{
FormatKind.Document or FormatKind.IsolatedSelection =>
service.FormatDocumentAsync(new Contracts.FormatDocumentRequest(originText, path, null), token),
service.FormatDocumentAsync(new Contracts.FormatDocumentRequest(originText, path, null, MakeCursorPosition(caret.BufferPosition)), token),
FormatKind.Selection =>
service.FormatSelectionAsync(new Contracts.FormatSelectionRequest(originText, path, null, MakeRange(vspan, path)), token),
_ => throw new NotSupportedException($"Operation {kind} is not supported")
Expand Down Expand Up @@ -359,6 +358,13 @@ async Task<InstallResult> LaunchDotnet(string caption, string args)
};
}

public static Contracts.FormatCursorPosition MakeCursorPosition(SnapshotPoint point)
{
var line = point.GetContainingLine();
var startCol = Math.Max(0, point.Position - line.Start.Position - 1);
return new Contracts.FormatCursorPosition(line.LineNumber + 1, startCol);
}

public static Contracts.FormatSelectionRange MakeRange(SnapshotSpan vspan, string path)
{
// Beware that the range argument is inclusive.
Expand Down
4 changes: 2 additions & 2 deletions src/FantomasVs.Shared/FantomasVs.Shared.projitems
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
Expand Down Expand Up @@ -27,7 +27,7 @@
<Compile Include="$(MSBuildThisFileDirectory)PredefinedCommandHandlerNames.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fantomas.Client" Version="0.4.0" />
<PackageReference Include="Fantomas.Client" Version="0.9.0" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)InstallChoice.xaml">
Expand Down
4 changes: 2 additions & 2 deletions src/FantomasVs.VS2022/FantomasVs.VS2022.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?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>
<MinimumVisualStudioVersion>17.0</MinimumVisualStudioVersion>
Expand Down Expand Up @@ -69,7 +69,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Fantomas.Client">
<Version>0.7.0</Version>
<Version>0.9.0</Version>
</PackageReference>
<PackageReference Include="DiffPlex">
<Version>1.7.1</Version>
Expand Down

0 comments on commit c9d60c9

Please sign in to comment.