Skip to content

Commit

Permalink
spel, more comment
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Feb 3, 2022
1 parent 7ac2d6d commit b11c18e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/host/directio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void EventsToUnicode(_Inout_ std::deque<std::unique_ptr<IInputEvent>>& inEvents,
// because a single codepoint might have been expanded into more
// that a single char.
//
// As of GH #8663, InputBuffer::Read will have pre-emptively
// As of GH #8663, InputBuffer::Read will have preemptively
// checked how much space each key is about to take up, and will
// only return as many as will fit in readBuffer _after_ a call
// to SplitToOem.
Expand Down
2 changes: 1 addition & 1 deletion src/host/inputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ void InputBuffer::_ReadBuffer(_Out_ std::deque<std::unique_ptr<IInputEvent>>& ou
}

// GH #8663: Before we read this key from the buffer, check that there's
// space for it. If we're calling Read without unidoce being set, then I
// space for it. If we're calling Read without unicode being set, then I
// believe we're also going to try and break this key event into one key
// for each OEM character. Problem is though, one unicode codepoint can
// be more than two chars long. So don't just use IsGlyphFullWidth,
Expand Down
2 changes: 1 addition & 1 deletion src/host/readDataDirect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ bool DirectReadData::Notify(const WaitTerminationReason TerminationReason,
// because a single codepoint might have been expanded into more
// that a single char.
//
// As of GH #8663, InputBuffer::Read will have pre-emptively
// As of GH #8663, InputBuffer::Read will have preemptively
// checked how much space each key is about to take up, and will
// only return as many as will fit in readBuffer _after_ a call
// to SplitToOem.
Expand Down
15 changes: 10 additions & 5 deletions src/host/ut_host/InputBufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class InputBufferTests
bool resetWaitEvent = false;

// GH #8663: We only insert 4 events. but we need to ask for 6 here.
// The Raised Hand emoji is U+270B in utf16, but it's 0xE2 0x9C 0x8B in utf-8.
// The hiragana A is U+3042 in utf16, but it turns into two chars in 932.
Log::Comment(fmt::format(L"Codepage: {}", ServiceLocator::LocateGlobals().getConsoleInformation().CP).c_str());
ServiceLocator::LocateGlobals().getConsoleInformation().CP = 932;
Log::Comment(fmt::format(L"Changed to: {}", ServiceLocator::LocateGlobals().getConsoleInformation().CP).c_str());
Expand Down Expand Up @@ -465,10 +465,12 @@ class InputBufferTests

TEST_METHOD(ReadingDbcsCharsPadsOutputArrayForEmoji)
{
// Basically the same test as ReadingDbcsCharsPadsOutputArray, but with
// emoji where 1 wchar can turn into 3 chars.
Log::Comment(L"During a utf-8 read, make sure the input buffer leaves "
L"enough room for keys that could be expanded into more than two chars.");

// write a mouse event, key event, dbcs key event, mouse event
// write a mouse event, key event, emoji key event, mouse event
InputBuffer inputBuffer;
const unsigned int recordInsertCount = 4;
INPUT_RECORD inRecords[recordInsertCount];
Expand All @@ -491,7 +493,7 @@ class InputBufferTests
size_t eventsRead = 0;
bool resetWaitEvent = false;

// GH #8663: We only insert 4 events. but we need to ask for 6 here.
// GH #8663: We only insert 4 events. but we need to ask for 5 here.
// The Raised Hand emoji is U+270B in utf16, but it's 0xE2 0x9C 0x8B in utf-8.
ServiceLocator::LocateGlobals().getConsoleInformation().CP = 65001;

Expand All @@ -503,10 +505,13 @@ class InputBufferTests
false,
false);

// the dbcs record should have counted for two elements in
// the array, making it so that we get less events read
// the emoji record should have counted for three elements in
// the array, making it so that we get less events read.
// We'll get the mouse, the key(A), and the key(U+270B)
VERIFY_ARE_EQUAL(3, eventsRead);
VERIFY_ARE_EQUAL(eventsRead, outEvents.size());

// The events we read back here are _not_ pre-translated to the active codepage.
for (size_t i = 0; i < eventsRead; ++i)
{
VERIFY_ARE_EQUAL(outEvents[i]->ToInputRecord(), inRecords[i]);
Expand Down

1 comment on commit b11c18e

@github-actions

This comment was marked as outdated.

Please sign in to comment.