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

Fix various cooked read issues #17556

Merged
merged 1 commit into from
Jul 15, 2024
Merged

Fix various cooked read issues #17556

merged 1 commit into from
Jul 15, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Jul 12, 2024

  • Wide glyphs that don't fit into the last column got treated
    as narrow glyphs which broke line layout.
  • Wide glyphs that don't fit into the last column got manually
    padded with whitespace which broke Ctrl+A + Ctrl+C in conhost.
  • Sudden increases/decreases in the pager height would leave
    parts of the viewport with leftover text and not clear it away.
  • Deleting an entire word at the start of a line would only delete
    its first two characters.

Closes #17554

@@ -1134,7 +1178,10 @@
const auto& line = lines.at(i + pagerContentTop);

// Skip lines that aren't marked as dirty.
if (line.dirtyBegOffset >= line.text.size())
// We use dirtyBegColumn instead of dirtyBegOffset to test for dirtiness, because a line that has 1 column
// of space for layout and was asked to fit a wide glyph will have no text, but stil be "dirty".

Check failure

Code scanning / check-spelling

Unrecognized Spelling

[stil](#security-tab) is not a recognized word. \(unrecognized-spelling\)
@lhecker lhecker force-pushed the dev/lhecker/17554-cooked-fixup branch from ff17a2a to 04c04b7 Compare July 12, 2024 16:07
@@ -445,7 +445,6 @@ size_t TextBuffer::FitTextIntoColumns(const std::wstring_view& chars, til::Coord
while (dist < len)
{
cwd.GraphemeNext(state, chars);
dist += state.len;
Copy link
Member Author

Choose a reason for hiding this comment

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

We shouldn't mark this grapheme as consumed (dist) if we'll early return in the if right below.

{
pagerPromptEnd.x = 0;
pagerPromptEnd.y++;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Modifying pagerPromptEnd like this throws off the if condition right after this one.

@@ -960,12 +955,14 @@ void COOKED_READ_DATA::_redisplay()
auto& line = lines.back();

// CSI K may be expensive, so use spaces if we can.
if (remaining <= 8)
if (remaining <= 16)
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 felt like 16 would be more appropriate for word-wise deletions.

Comment on lines -1246 to -1250
if (it != end && column < columnLimit)
{
output.append(columnLimit - column, L' ');
column = columnLimit;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Removing this stops us from inserting padding spaces manually (that's the job of the terminal). But with the if condition gone, we need to move the column = columnLimit; elsewhere of course, because otherwise the caller doesn't know that we line-wrapped.

@DHowett DHowett enabled auto-merge July 12, 2024 19:17
@DHowett DHowett added this pull request to the merge queue Jul 15, 2024
Merged via the queue into main with commit ee09ec2 Jul 15, 2024
20 checks passed
@DHowett DHowett deleted the dev/lhecker/17554-cooked-fixup branch July 15, 2024 12:01
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.

Backspace in wrapped cooked read erases char on line above
3 participants