Skip to content

Commit 34ecc5b

Browse files
authored
Fix conpty cursor movement detection on double-width lines (microsoft#17233)
When the VT render engine checks whether the cursor has moved in the `InvalidateCursor` method, it does so by comparing the origin of the given cursor region with the last text output coordinates. But these two values are actually from different coordinate systems, and when on a double-width line, the x text coordinate is half of the corresponding screen coordinate. As a result, the movement detection is sometimes incorrect. This PR fixes the issue by adding another field to track the last cursor origin in screen coordinates, so we have a meaningful value to compare against. ## References and Relevant Issues The previous cursor movement detection was added in PR microsoft#17194 to fix issue microsoft#17117. ## Validation Steps Performed I've confirmed that the test case from issue microsoft#17232 is now fixed, and the test case from issue microsoft#17117 is still working as expected. ## PR Checklist - [x] Closes microsoft#17232
1 parent 44516ad commit 34ecc5b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/renderer/vt/invalidate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ CATCH_RETURN();
7575
}
7676
_skipCursor = false;
7777

78-
_cursorMoved = psrRegion->origin() != _lastText;
78+
_cursorMoved = psrRegion->origin() != _lastCursorOrigin;
79+
_lastCursorOrigin = psrRegion->origin();
7980
return S_OK;
8081
}
8182

src/renderer/vt/vtrenderer.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ namespace Microsoft::Console::Render
111111
til::pmr::bitmap _invalidMap;
112112

113113
til::point _lastText;
114+
til::point _lastCursorOrigin;
114115
til::point _scrollDelta;
115116

116117
bool _clearedAllThisFrame;

0 commit comments

Comments
 (0)