Skip to content

Commit

Permalink
I thought I could be clever and solve #32 and #12567 at the same time…
Browse files Browse the repository at this point in the history
…. I was worng.

  My theory was "fuck perf, let's do it right, and figure out perf later". It didn't work.
  This wraps lines super weird, probably because I'm copying the whole line to the right side of the row, which is then starting to mark it as wrapped.
  Also like the test doesn't even pass.
  • Loading branch information
zadjii-msft committed Mar 2, 2022
1 parent 444f7df commit a8d3364
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/buffer/out/AttrRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,19 @@ ATTR_ROW::const_iterator ATTR_ROW::cbegin() const noexcept
{
return _data.cbegin();
}
ATTR_ROW::const_reverse_iterator ATTR_ROW::crbegin() const noexcept
{
return _data.crbegin();
}

ATTR_ROW::const_iterator ATTR_ROW::cend() const noexcept
{
return _data.cend();
}
ATTR_ROW::const_reverse_iterator ATTR_ROW::crend() const noexcept
{
return _data.crend();
}

bool operator==(const ATTR_ROW& a, const ATTR_ROW& b) noexcept
{
Expand Down
3 changes: 3 additions & 0 deletions src/buffer/out/AttrRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class ATTR_ROW final

public:
using const_iterator = rle_vector::const_iterator;
using const_reverse_iterator = rle_vector::const_reverse_iterator;

ATTR_ROW(uint16_t width, TextAttribute attr);

Expand All @@ -52,7 +53,9 @@ class ATTR_ROW final
const_iterator end() const noexcept;

const_iterator cbegin() const noexcept;
const_reverse_iterator crbegin() const noexcept;
const_iterator cend() const noexcept;
const_reverse_iterator crend() const noexcept;

friend bool operator==(const ATTR_ROW& a, const ATTR_ROW& b) noexcept;
friend class ROW;
Expand Down
8 changes: 8 additions & 0 deletions src/buffer/out/CharRow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ typename CharRow::const_iterator CharRow::cbegin() const noexcept
{
return _data.cbegin();
}
typename CharRow::const_reverse_iterator CharRow::crbegin() const noexcept
{
return _data.crbegin();
}

typename CharRow::iterator CharRow::end() noexcept
{
Expand All @@ -86,6 +90,10 @@ typename CharRow::const_iterator CharRow::cend() const noexcept
{
return _data.cend();
}
typename CharRow::const_reverse_iterator CharRow::crend() const noexcept
{
return _data.crend();
}

// Routine Description:
// - Inspects the current internal string to find the left edge of it
Expand Down
2 changes: 2 additions & 0 deletions src/buffer/out/CharRow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,12 @@ class CharRow final
iterator begin() noexcept;
const_iterator cbegin() const noexcept;
const_iterator begin() const noexcept { return cbegin(); }
const_reverse_iterator crbegin() const noexcept;

iterator end() noexcept;
const_iterator cend() const noexcept;
const_iterator end() const noexcept { return cend(); }
const_reverse_iterator crend() const noexcept;

UnicodeStorage& GetUnicodeStorage() noexcept;
const UnicodeStorage& GetUnicodeStorage() const noexcept;
Expand Down
14 changes: 8 additions & 6 deletions src/buffer/out/Row.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,18 @@ size_t ROW::MeasureRightIsh() const
// ++it;
// }
// return _data.crend() - it;
auto charIter = _charRow.cbegin();
auto attrIter = _attrRow.cbegin();
auto charIter = _charRow.crbegin();
auto attrIter = _attrRow.crbegin();
const TextAttribute defaultColor{};
while (charIter != _charRow.cend() &&
attrIter != _attrRow.cend() &&
while (charIter != _charRow.crend() &&
attrIter != _attrRow.crend() &&
// (!charIter->IsSpace() || *attrIter != defaultColor))
(!charIter->IsSpace() || !attrIter->HasIdenticalVisualRepresentationForBlankSpace(defaultColor)))
// (!charIter->IsSpace() || !attrIter->HasIdenticalVisualRepresentationForBlankSpace(defaultColor)))
(charIter->IsSpace() && attrIter->HasIdenticalVisualRepresentationForBlankSpace(defaultColor)))
{
++charIter;
++attrIter;
}
return charIter - _charRow.cbegin() - 1;
// return charIter - _charRow.cbegin() - 1;
return _charRow.crend() - charIter;
}
5 changes: 4 additions & 1 deletion src/host/ut_host/TextBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2708,6 +2708,9 @@ void TextBufferTests::NoHyperlinkTrim()

void TextBufferTests::TestMeasureRightIsh()
{
// Continue on failures
const WEX::TestExecution::DisableVerifyExceptions disableExceptionsScope;

CONSOLE_INFORMATION& gci = ServiceLocator::LocateGlobals().getConsoleInformation();
SCREEN_INFORMATION& si = gci.GetActiveOutputBuffer().GetActiveBuffer();
const TextBuffer& tbi = si.GetTextBuffer();
Expand All @@ -2718,7 +2721,7 @@ void TextBufferTests::TestMeasureRightIsh()
// const auto foreground = RGB(40, 40, 40);
// const auto background = RGB(168, 153, 132);

// const wchar_t* const sequence = L"\x1b[38;2;40;40;40m\x1b[48;2;168;153;132mX\x1b[1mX\x1b[m";
// TODO! version of the test without the clear and reset to default colors.
const wchar_t* const sequence = L"\x1b[0m\x1b[2J\x1b[3JFoo\nBar Baz\n\x1b[41mFoo\n\x1b[42m bar \x1b[44m baz \n\x1b[48m foo \x1b[m";
stateMachine.ProcessString(sequence);
// const auto x = cursor.GetPosition().X;
Expand Down

1 comment on commit a8d3364

@github-actions
Copy link

@github-actions github-actions bot commented on a8d3364 Mar 2, 2022

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:

  • JFoo
Previously acknowledged words that are now absent azurewebsites cxcy debolden deconstructed devicefamily guardxfg LLVM MSDL ned NOWAIT pgorepro pgort PGU redistributable Timeline timelines unintense WResult xfg
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 git@github.com:microsoft/terminal.git repository
on the dev/migrie/b/32-but-im-here-for-12567 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/a8d336416a2be63e25c21fbb4ba51785fd7894fd.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/67788114" > "$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.