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 backspacing over control visualizers #16400

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/COOKED_READ_DATA.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ All of the following ✅ marks must be fulfilled during manual testing:
* Press tab: Autocomplete to "a😊b.txt" ✅
* Navigate the cursor right past the "a"
* Press tab twice: Autocomplete to "a😟b.txt" ✅
* Execute `printf(" "); gets(buffer);` in C (or equivalent)
* Press Tab, A, Ctrl+V, Tab, A ✅
* The prompt is " A^V A" ✅
* Cursor navigation works ✅
* Backspacing/Deleting random parts of it works ✅
* It never deletes the initial 4 spaces ✅
* Backspace deletes preceding glyphs ✅
* Ctrl+Backspace deletes preceding words ✅
* Escape clears input ✅
Expand Down
19 changes: 14 additions & 5 deletions src/host/readDataCooked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -938,22 +938,31 @@ ptrdiff_t COOKED_READ_DATA::_writeCharsImpl(const std::wstring_view& text, const
const auto wch = *it;
if (wch == UNICODE_TAB)
{
const auto col = _getColumnAtRelativeCursorPosition(distance + cursorOffset);
const auto remaining = width - col;
distance += std::min(remaining, 8 - (col & 7));
buf[0] = L'\t';
len = 1;
}
else
{
// In the interactive mode we replace C0 control characters (0x00-0x1f) with ASCII representations like ^C (= 0x03).
distance += 2;
buf[0] = L'^';
buf[1] = gsl::narrow_cast<wchar_t>(wch + L'@');
len = 2;
}

if (!measureOnly)
if (measureOnly)
{
if (wch == UNICODE_TAB)
{
const auto col = _getColumnAtRelativeCursorPosition(distance + cursorOffset);
const auto remaining = width - col;
distance += std::min(remaining, 8 - (col & 7));
}
else
{
distance += 2;
}
}
else
{
distance += _writeCharsUnprocessed({ &buf[0], len });
}
Expand Down
Loading