Skip to content

Commit

Permalink
Added VS 2019 support
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed Jan 6, 2022
1 parent ff34020 commit eaa4ace
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 24 deletions.
10 changes: 8 additions & 2 deletions src/Commands/ShiftDownCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ public static void Shift(DocumentView docView, ShiftDirection direction)
SnapshotSpan selection = GetSelectedSpan(docView.TextView, caretPosition);

string text = selection.GetText();
int start = caretPosition - selection.Start;

if (ShiftEngine.TryShift(text, caretPosition - selection.Start, direction, out ShiftResult result))
if (ShiftEngine.TryShift(text, start, direction, out ShiftResult result))
{
// Update text buffer
Span span = new(result.Start + selection.Start, result.Length);
ITextSnapshot snapshot = docView.TextBuffer.Replace(span, result.ShiftedText);

SnapshotPoint point = new(snapshot, caretPosition.Position);
// Maintain caret position
Span newSpan = new(result.Start + selection.Start, result.ShiftedText.Length);
int endPosition = newSpan.Contains(caretPosition) ? caretPosition : newSpan.End;
SnapshotPoint point = new(snapshot, endPosition);
docView.TextView.Caret.MoveTo(point);

// Select the new text
docView.TextView.Selection.Select(new SnapshotSpan(snapshot, span.Start, result.ShiftedText.Length), false);
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/Shifter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Community.VisualStudio.VSCT" Version="16.0.29.6" PrivateAssets="all" />
<PackageReference Include="Community.VisualStudio.Toolkit.17" Version="17.0.355" ExcludeAssets="Runtime">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Community.VisualStudio.Toolkit.16" Version="16.0.355" ExcludeAssets="Runtime" />
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.0.5232" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
39 changes: 20 additions & 19 deletions src/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="Shifter.2788249e-f649-4ef6-a0e4-e390ccdbe588" Version="1.0" Language="en-US" Publisher="Mads Kristensen" />
<DisplayName>Shifter</DisplayName>
<Description xml:space="preserve">String and code manipulations, performed on keyboard shortcut with detection of intended manipulation.</Description>
<License>Resources\LICENSE</License>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\Icon.png</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[17.0,)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
<Metadata>
<Identity Id="Shifter.2788249e-f649-4ef6-a0e4-e390ccdbe588" Version="1.0" Language="en-US" Publisher="Mads Kristensen" />
<DisplayName>Shifter</DisplayName>
<Description xml:space="preserve">String and code manipulations, performed on keyboard shortcut with detection of intended manipulation.</Description>
<License>Resources\LICENSE</License>
<Icon>Resources\Icon.png</Icon>
<PreviewImage>Resources\Icon.png</PreviewImage>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0, 17.0)" />
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0, 18.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Prerequisites>
<Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[16.0,)" DisplayName="Visual Studio core editor" />
</Prerequisites>
<Assets>
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
</PackageManifest>

0 comments on commit eaa4ace

Please sign in to comment.