-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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 line breaks in the debug tap output #13475
Conversation
for (size_t lfPos = 0; (lfPos = output.find(L'\u240A', lfPos)) != std::wstring::npos;) | ||
{ | ||
output.insert(++lfPos, L"\r\n"); | ||
} |
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.
I'm fine with this.
Although I'd generally prefer it if til::visualize_control_codes
was decomposed, so that we can "recompose" it back into the two behaviors we need (namely newline preserving and not). Something like that:
namespace til
{
constexpr wchar_t visualize_control_code(wchar_t ch) noexcept
{
if (ch < 0x20)
{
ch += 0x2400;
}
else if (ch == 0x20)
{
ch = 0x2423; // replace space with ␣
}
else if (ch == 0x7f)
{
ch = 0x2421; // replace del with ␡
}
return ch;
}
_TIL_INLINEPREFIX std::wstring visualize_control_codes(std::wstring str) noexcept
{
for (auto& ch : str)
{
ch = visualize_control_code(ch);
}
return str;
}
_TIL_INLINEPREFIX std::wstring visualize_control_codes_with_newlines(std::wstring_view str) noexcept
{
std::wstring out;
out.reserve(str.size());
wchar_t buffer[3]{ L'\0', L'\r', L'\n' };
for (const auto& ch : str)
{
buffer[0] = visualize_control_code(ch);
const auto length = buffer[0] != 0x240A ? 1 : 3;
out.append(&buffer[0], length);
}
return out;
}
}
(I haven't tested, nor commented it, but I think it should work. The main benefit is that it doesn't need to reshuffle the string so that it's only a single O(n)
loop.)
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.
I agree, but also... this is an "under duress" debugging feature. It's going to impact performance, even if negligibly, but it is on a low-use surface. I'm cool with it.
I know you probably approved instead of blocking because you're aware of that already. :)
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.
I know you probably approved instead of blocking because you're aware of that already. :)
^ This. 🙂
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.
Sorry. I guess this was a bit lazy of me, but I didn't want to mess with the existing code, and I figured the performance wasn't that important here.
for (size_t lfPos = 0; (lfPos = output.find(L'\u240A', lfPos)) != std::wstring::npos;) | ||
{ | ||
output.insert(++lfPos, L"\r\n"); | ||
} |
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.
I agree, but also... this is an "under duress" debugging feature. It's going to impact performance, even if negligibly, but it is on a low-use surface. I'm cool with it.
I know you probably approved instead of blocking because you're aware of that already. :)
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
## Summary of the Pull Request When the debug tap converts control characters into visible glyphs, it ends up losing the structure of the output, and that can sometimes make things difficult to read. This PR attempts to alleviate that problem by reinjecting an actual line break in the debug stream whenever an `LF` control is received. ## PR Checklist * [x] Closes #12312 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. Issue number where discussion took place: #12312 ## Validation Steps Performed I've tested the updated debug tab with a number of different shells, and also a couple of different apps. When there aren't many linefeeds in the output, it's obviously not going to make much of a difference, but when there are, I think it definitely improves the readability. (cherry picked from commit 04478d1) Service-Card-Id: 84116394 Service-Version: 1.14
## Summary of the Pull Request When the debug tap converts control characters into visible glyphs, it ends up losing the structure of the output, and that can sometimes make things difficult to read. This PR attempts to alleviate that problem by reinjecting an actual line break in the debug stream whenever an `LF` control is received. ## PR Checklist * [x] Closes #12312 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [x] I've discussed this with core contributors already. Issue number where discussion took place: #12312 ## Validation Steps Performed I've tested the updated debug tab with a number of different shells, and also a couple of different apps. When there aren't many linefeeds in the output, it's obviously not going to make much of a difference, but when there are, I think it definitely improves the readability. (cherry picked from commit 04478d1) Service-Card-Id: 84116395 Service-Version: 1.15
🎉 Handy links: |
🎉 Handy links: |
Summary of the Pull Request
When the debug tap converts control characters into visible glyphs, it
ends up losing the structure of the output, and that can sometimes make
things difficult to read. This PR attempts to alleviate that problem by
reinjecting an actual line break in the debug stream whenever an
LF
control is received.
PR Checklist
\n
when\r
is received #12312where discussion took place: Add an additional debug option to show a
\n
when\r
is received #12312Validation Steps Performed
I've tested the updated debug tab with a number of different shells, and
also a couple of different apps. When there aren't many linefeeds in the
output, it's obviously not going to make much of a difference, but when
there are, I think it definitely improves the readability.