-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from lordfanger/master
Incremental shifts feature + tests + fixes [release]
- Loading branch information
Showing
16 changed files
with
237 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Shifter.Providers; | ||
|
||
namespace Shifter | ||
{ | ||
[Command(PackageIds.IncrementalShiftDown)] | ||
internal sealed class IncrementalShiftDownCommand : BaseCommand<IncrementalShiftDownCommand> | ||
{ | ||
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) | ||
{ | ||
DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); | ||
|
||
if (docView?.TextView == null) | ||
{ | ||
return; | ||
} | ||
|
||
ShiftDownCommand.Shift(docView, ShiftDirection.Down, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Shifter.Providers; | ||
|
||
namespace Shifter | ||
{ | ||
[Command(PackageIds.IncrementalShiftUp)] | ||
internal sealed class IncrementalShiftUpCommand : BaseCommand<IncrementalShiftUpCommand> | ||
{ | ||
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) | ||
{ | ||
DocumentView docView = await VS.Documents.GetActiveDocumentViewAsync(); | ||
|
||
if (docView?.TextView == null) | ||
{ | ||
return; | ||
} | ||
|
||
ShiftDownCommand.Shift(docView, ShiftDirection.Up, true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Shifter.Providers | ||
{ | ||
public interface IIncrementalProvider : IProvider | ||
{ | ||
bool TryShiftLine(string textIn, int caretPosition, ShiftDirection direction, int sequence, out ShiftResult result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Shifter.Providers | ||
{ | ||
public abstract class IncrementalRegexProviderBase : RegexProviderBase, IIncrementalProvider | ||
{ | ||
/// <inheritdoc /> | ||
public bool TryShiftLine(string textIn, int caretPosition, ShiftDirection direction, int sequence, out ShiftResult result) | ||
{ | ||
result = null; | ||
MatchCollection matches = Regex.Matches(textIn); | ||
|
||
if (matches.Count == 0) | ||
{ | ||
return false; | ||
} | ||
|
||
foreach (Match match in matches) | ||
{ | ||
int start = match.Index; | ||
int end = match.Index + match.Length; | ||
|
||
if (caretPosition >= start && caretPosition <= end) | ||
{ | ||
return TryShiftSelection(match, direction, sequence, out result); | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public override bool TryShiftSelection(Match match, ShiftDirection direction, out ShiftResult result) => TryShiftSelection(match, direction, 0, out result); | ||
|
||
public abstract bool TryShiftSelection(Match match, ShiftDirection direction, int sequence, out ShiftResult result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.