Skip to content
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

Remove dependency on IsGlyphFullWidth for IRM/DECSWL #16903

Merged
merged 6 commits into from
Apr 10, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Mar 19, 2024

This gets rid off the implicit dependency on IsGlyphFullWidth
for the IRM and DECSWL/DECDWL/DECDHL implementations.

Validation Steps Performed

In pwsh:

  • "`e[31mab`e[m`b`e[4h`e[32m$('*'*10)`e[m`e[4l"
    prints a red "a", 10 green "*" and a red "b" ✅
  • "`e[31mab`e[m`b`e[4h`e[32m$('*'*1000)`e[m`e[4l"
    prints a red "a" and a couple lines of green "*" ✅
  • "`e[31mf$('o'*70)`e[m`e#6`e#5"
    the right half of the row is erased ✅

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Amazing! I see a lot of tests moved to use Replace as well... which makes me think that we should have tests for Insert, right?

@lhecker
Copy link
Member Author

lhecker commented Mar 19, 2024

Amazing! I see a lot of tests moved to use Replace as well... which makes me think that we should have tests for Insert, right?

I fear you may have mistaken COOKED_READ_DATA for tests since it's so repetitive. Currently TextBuffer::Replace is mostly covered via integration tests via the VT unit and Host unit/feature test projects. The test coverage is pretty good I think. We also have IRM tests which cover the TextBuffer::Insert call but its coverage is not as good.

We do have a pretty good unit test coverage of ROW::ReplaceText though, which I think is the most important one. Both TextBuffer::Replace and TextBuffer::Insert are based on that function after all.

@DHowett
Copy link
Member

DHowett commented Mar 19, 2024

I fear you may have mistaken COOKED_READ_DATA for tests since it's so repetitive.

I sure did!

Comment on lines +124 to +127
if (_modes.test(Mode::InsertReplace))
{
textBuffer.Insert(cursorPosition.y, attributes, state);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't working correctly when you have horizontal margins set. If you're inserting text while inside the margins, the content that is pushed to the right should only move as far as the right margin. I didn't look at the implementation that closely, but I'm guessing the Insert method is not taking the state.columnLimit into account.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Test case in pwsh:

"`e7`e[?69h`e[1;20s`e8*`e[19b`r`e[4h `e[19b`e[4l`e[s`e8`n"

That should produce what is effectively a blank line, but instead we're seeing 20 * characters offset by 20 columns.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe I fixed this issue. Thanks!

I noticed that after running your test string, TextBuffer::SetCurrentLineRendition won't get called anymore. Is that to be expected? (It does work again after emitting a RIS.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

I didn't think about that, but that is actually correct. When the horizontal margin mode is enabled, line renditions are disabled. I should have reset mode ?69 at the end of that test case.

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

I think I trust this?

@DHowett DHowett enabled auto-merge March 28, 2024 22:32
@DHowett DHowett disabled auto-merge March 28, 2024 23:31
Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

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

Test

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Mar 28, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Apr 2, 2024
src/host/ut_host/TextBufferTests.cpp Fixed Show fixed Hide fixed
src/host/ut_host/TextBufferTests.cpp Fixed Show fixed Hide fixed
src/host/ut_host/TextBufferTests.cpp Fixed Show fixed Hide fixed
{
return WEX::Common::NoThrowString(object.to_string().c_str());
}
};
Copy link
Member Author

Choose a reason for hiding this comment

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

...yes. 😑
Let me know if you dislike this removal. rle_vector uses strstream like all the other classes and TextAttribute has no string-serializer. I just removed it because it was easier. I could however write a full ToString method here if we want to.

Copy link
Member

Choose a reason for hiding this comment

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

yeah honestly I don't particularly care for all of these

This comment has been minimized.

@microsoft microsoft deleted a comment Apr 10, 2024
@lhecker lhecker added this pull request to the merge queue Apr 10, 2024
Merged via the queue into main with commit 4fd15c9 Apr 10, 2024
20 checks passed
@lhecker lhecker deleted the dev/lhecker/irm-IsGlyphFullWidth branch April 10, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants