Skip to content

Commit

Permalink
Fix failing UIA movement tests (#10991)
Browse files Browse the repository at this point in the history
## Summary of the Pull Request
Follow-up for #10886. The new UIA movement tests found some failing cases. This PR fixes UiaTextRangeBase to have movement match that of MS Word. In total, this fixes 64 tests.

## PR Checklist
* [X] Closes #10924
* [X] Tests added/passed

## Detailed Description of the Pull Request / Additional comments
Root causes include...
1. if we were a non-degenerate range and we failed to move, we should still expand to enclose the unit
2. non-degenerate ranges are treated as if they already encompassed their given unit.
   - this one is a bit difficult to explain. Consider these examples:
      1. document movement
         - state: you have a 1-cell wide range on the buffer, and you try to move by document
         - result: move by 0 (there is no next/prev document), but the range now encompasses the entire document
      2. line movement
         - state: you have a 1-cell wide range on a line, and you try to move back by a line
         - result: you go to the previous line (not the beginning of this line)
   - conversely, a degenerate range successfully moves to the beginning/end of the current unit (i.e. document/line)
   - this (bizarre) behavior was confirmed using MS Word

As a bonus, occasionally, Narrator would get stuck when navigating by line. This issue now seems to be fixed.

## Updates to existing tests
- `CanMoveByCharacter`
   - `can't move backward from (0, 0)` --> misauthored, result should be one character wide.
   - `can't move past the last column in the last row` --> misauthored and already covered in generated tests
- `CanMoveByLine`
   - `can't move backward from top row` --> misauthored, end should be on next line. Already covered by generated tests
   - `can't move forward from bottom row` --> misauthored, end should be on next line
   - `can't move backward when part of the top row is in the range` --> misauthored, should expand
   - `can't move forward when part of the bottom row is in the range` --> misauthored, degenerate range moves to end of buffer
- `MovementAtExclusiveEnd`
   - populate the text buffer _before_ we do a move by word operation
   - update to match the now fixed behavior
  • Loading branch information
carlos-zamora authored and DHowett committed Aug 25, 2021
1 parent 5abb574 commit 9ac7ce2
Show file tree
Hide file tree
Showing 5 changed files with 153 additions and 212 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 -1 times by Line",
GeneratedMovementTestInput{
Expand All @@ -551,7 +551,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 0 times by Line",
GeneratedMovementTestInput{
Expand All @@ -563,7 +563,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 1 times by Line",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -599,7 +599,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
-1,
origin,
origin },
true },
false },
GeneratedMovementTest{
L"Move degenerate range at position 2 -1 times by Line",
GeneratedMovementTestInput{
Expand All @@ -611,7 +611,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
-1,
origin,
origin },
true },
false },
GeneratedMovementTest{
L"Move degenerate range at position 2 0 times by Line",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -659,7 +659,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 -1 times by Line",
GeneratedMovementTestInput{
Expand All @@ -671,7 +671,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 0 times by Line",
GeneratedMovementTestInput{
Expand All @@ -683,7 +683,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
originP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 1 times by Line",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -779,7 +779,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
-5,
midHistoryM5L,
midHistoryM4L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 -1 times by Line",
GeneratedMovementTestInput{
Expand All @@ -791,7 +791,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
-1,
midHistoryM1L,
midHistoryLeft },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 0 times by Line",
GeneratedMovementTestInput{
Expand All @@ -803,7 +803,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
midHistoryLeft,
midHistoryP1L },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 1 times by Line",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -873,9 +873,9 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
origin },
GeneratedMovementTestExpected{
1,
docEnd,
docEnd },
true },
endExclusive,
endExclusive },
false },
GeneratedMovementTest{
L"Move degenerate range at position 1 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -885,9 +885,9 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
origin },
GeneratedMovementTestExpected{
1,
docEnd,
docEnd },
true },
endExclusive,
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 -5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -898,8 +898,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
docEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 -1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -910,8 +910,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
docEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 0 times by Document",
GeneratedMovementTestInput{
Expand All @@ -922,8 +922,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
docEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -934,8 +934,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
docEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 1 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -946,8 +946,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
docEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move degenerate range at position 2 -5 times by Document",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -993,9 +993,9 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
midTop },
GeneratedMovementTestExpected{
1,
bufferEnd,
bufferEnd },
true },
endExclusive,
endExclusive },
false },
GeneratedMovementTest{
L"Move degenerate range at position 2 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1005,9 +1005,9 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
midTop },
GeneratedMovementTestExpected{
1,
bufferEnd,
bufferEnd },
true },
endExclusive,
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 -5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1018,8 +1018,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
bufferEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 -1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1030,8 +1030,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
bufferEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 0 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1042,8 +1042,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
bufferEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1054,8 +1054,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
bufferEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 2 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1066,8 +1066,8 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
GeneratedMovementTestExpected{
0,
origin,
bufferEnd },
true },
endExclusive },
false },
GeneratedMovementTest{
L"Move degenerate range at position 3 -5 times by Document",
GeneratedMovementTestInput{
Expand Down Expand Up @@ -1115,7 +1115,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
1,
endExclusive,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move degenerate range at position 3 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1127,7 +1127,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
1,
endExclusive,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 -5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1139,7 +1139,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 -1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1151,7 +1151,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 0 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1163,7 +1163,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 1 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1175,7 +1175,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move non-degenerate range at position 3 5 times by Document",
GeneratedMovementTestInput{
Expand All @@ -1187,7 +1187,7 @@ static constexpr std::array<GeneratedMovementTest, 255> s_movementTests{
0,
origin,
endExclusive },
true },
false },
GeneratedMovementTest{
L"Move degenerate range at position 8 -5 times by Character",
GeneratedMovementTestInput{
Expand Down
Loading

1 comment on commit 9ac7ce2

@github-actions
Copy link

@github-actions github-actions bot commented on 9ac7ce2 Aug 25, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@check-spelling-bot Report

Unrecognized words, please review:

  • apimswincoresynchl
  • comparand
  • cppm
  • intrin
  • ixx
  • MSAA
  • packagename
  • sdkddkver
  • SRWLOC
  • SRWLOCK
  • TLDR
  • wght
  • winsdkver
Previously acknowledged words that are now absent ADDB debounce FILETIME hpcon scprintf serializers testnetv Tlg VPrintf xIcon Xpath yIcon
To accept these unrecognized words as correct (and remove the previously acknowledged and now absent words), run the following commands

... in a clone of the [email protected]:microsoft/terminal.git repository
on the release-1.10 branch:

update_files() {
perl -e '
my @expect_files=qw('".github/actions/spelling/expect/alphabet.txt
.github/actions/spelling/expect/expect.txt
.github/actions/spelling/expect/web.txt"');
@ARGV=@expect_files;
my @stale=qw('"$patch_remove"');
my $re=join "|", @stale;
my $suffix=".".time();
my $previous="";
sub maybe_unlink { unlink($_[0]) if $_[0]; }
while (<>) {
if ($ARGV ne $old_argv) { maybe_unlink($previous); $previous="$ARGV$suffix"; rename($ARGV, $previous); open(ARGV_OUT, ">$ARGV"); select(ARGV_OUT); $old_argv = $ARGV; }
next if /^(?:$re)(?:(?:\r|\n)*$| .*)/; print;
}; maybe_unlink($previous);'
perl -e '
my $new_expect_file=".github/actions/spelling/expect/9ac7ce2082f1139ce0c4feae09d02b7a9234020c.txt";
use File::Path qw(make_path);
use File::Basename qw(dirname);
make_path (dirname($new_expect_file));
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"$patch_add"');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a)."-".$a cmp lc($b)."-".$b} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;
system("git", "add", $new_expect_file);
'
}

comment_json=$(mktemp)
curl -L -s -S \
  --header "Content-Type: application/json" \
  "https://api.github.com/repos/microsoft/terminal/comments/55440030" > "$comment_json"
comment_body=$(mktemp)
jq -r .body < "$comment_json" > $comment_body
rm $comment_json

patch_remove=$(perl -ne 'next unless s{^</summary>(.*)</details>$}{$1}; print' < "$comment_body")
  

patch_add=$(perl -e '$/=undef;
$_=<>;
s{<details>.*}{}s;
s{^#.*}{};
s{\n##.*}{};
s{(?:^|\n)\s*\*}{}g;
s{\s+}{ }g;
print' < "$comment_body")
  
update_files
rm $comment_body
git add -u
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

⚠️ The command is written for posix shells. You can copy the contents of each perl command excluding the outer ' marks and dropping any '"/"' quotation mark pairs into a file and then run perl file.pl from the root of the repository to run the code. Alternatively, you can manually insert the items...

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

🗜️ If you see a bunch of garbage

If it relates to a ...

well-formed pattern

See if there's a pattern that would match it.

If not, try writing one and adding it to a patterns/{file}.txt.

Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

Note that patterns can't match multiline strings.

binary-ish string

Please add a file path to the excludes.txt file instead of just accepting the garbage.

File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

Please sign in to comment.