-
Notifications
You must be signed in to change notification settings - Fork 8.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mutex to keyEvents in TermControlAutomationPeer #14694
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
{ | ||
if (const auto keyEventChar{ gsl::narrow_cast<wchar_t>(charCode) }; IsReadable({ &keyEventChar, 1 })) | ||
{ | ||
_keyEvents.emplace_back(keyEventChar); | ||
_keyEvents.lock()->emplace_back(keyEventChar); | ||
} | ||
} | ||
} | ||
|
@@ -202,27 +202,30 @@ namespace winrt::Microsoft::Terminal::Control::implementation | |
|
||
void TermControlAutomationPeer::NotifyNewOutput(std::wstring_view newOutput) | ||
{ | ||
// Try to suppress any events (or event data) | ||
// that is just the keypress the user made | ||
auto sanitized{ Sanitize(newOutput) }; | ||
while (!_keyEvents.empty() && IsReadable(sanitized)) | ||
// Try to suppress any events (or event data) | ||
// that are just the keypresses the user made | ||
{ | ||
if (til::toupper_ascii(sanitized.front()) == _keyEvents.front()) | ||
{ | ||
// the key event's character (i.e. the "A" key) matches | ||
// the output character (i.e. "a" or "A" text). | ||
// We can assume that the output character resulted from | ||
// the pressed key, so we can ignore it. | ||
sanitized = sanitized.substr(1); | ||
_keyEvents.pop_front(); | ||
} | ||
else | ||
auto keyEvents = _keyEvents.lock(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, but this returns a proxy object... so really it doesn't matter. You're actually using a |
||
while (!keyEvents->empty() && IsReadable(sanitized)) | ||
{ | ||
// The output doesn't match, | ||
// so clear the input stack and | ||
// move on to fire the event. | ||
_keyEvents.clear(); | ||
break; | ||
if (til::toupper_ascii(sanitized.front()) == keyEvents->front()) | ||
{ | ||
// the key event's character (i.e. the "A" key) matches | ||
// the output character (i.e. "a" or "A" text). | ||
// We can assume that the output character resulted from | ||
// the pressed key, so we can ignore it. | ||
sanitized = sanitized.substr(1); | ||
keyEvents->pop_front(); | ||
} | ||
else | ||
{ | ||
// The output doesn't match, | ||
// so clear the input stack and | ||
// move on to fire the event. | ||
keyEvents->clear(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lhecker this is an acceptable use of lock(), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the guard should get destroyed at
;
(= after the insertion finished).