mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Handle wrap-pending cursor in row highlight
This commit is contained in:
1 parent
e2fb4251fe
commit
ed4e02e96f
2 files changed
+20
-2
No files matched your search
@@ -274,6 +274,24 @@ test('CursorLineHighlighter leaves the cursor cell above the blank tail', () =>
|
||||
highlighter.dispose();
|
||||
});
|
||||
|
||||
test('CursorLineHighlighter clamps a wrap-pending cursor to the last cell', () => {
|
||||
const term = createFakeTerm(10);
|
||||
term.setLineLength(4);
|
||||
term.setCursorX(10);
|
||||
const highlighter = new CursorLineHighlighter(term as never);
|
||||
highlighter.setBackgroundColor('#263449');
|
||||
highlighter.setEnabled(true);
|
||||
|
||||
assert.deepEqual(
|
||||
term.decorations.map(({ options }) => ({ x: options.x, width: options.width })),
|
||||
[
|
||||
{ x: 0, width: 4 },
|
||||
{ x: 4, width: 5 },
|
||||
],
|
||||
);
|
||||
highlighter.dispose();
|
||||
});
|
||||
|
||||
test('CursorLineHighlighter leaves colored and inverse cells untouched', () => {
|
||||
const term = createFakeTerm(10);
|
||||
term.setColoredForegrounds([2, 3]);
|
||||
|
||||
@@ -217,8 +217,8 @@ export class CursorLineHighlighter implements IDisposable {
|
||||
|
||||
private getTailRanges(contentEnd: number, cols: number, cursorX: number): HighlightRange[] {
|
||||
if (contentEnd >= cols) return [];
|
||||
const cursorColumn = cursorX >= 0 && cursorX < cols ? cursorX : null;
|
||||
if (cursorColumn === null || cursorColumn < contentEnd) {
|
||||
const cursorColumn = Math.min(Math.max(cursorX, 0), cols - 1);
|
||||
if (cursorColumn < contentEnd) {
|
||||
return [{ x: contentEnd, width: cols - contentEnd }];
|
||||
}
|
||||
return [
|
||||
|
||||
Reference in new issue
Block a user