mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
renderer/metal: handle preedit wider than our screen
This commit is contained in:
@ -1101,10 +1101,9 @@ fn rebuildCells(
|
|||||||
y: usize,
|
y: usize,
|
||||||
x: [2]usize,
|
x: [2]usize,
|
||||||
} = if (preedit) |preedit_v| preedit: {
|
} = if (preedit) |preedit_v| preedit: {
|
||||||
var x = screen.cursor.x;
|
|
||||||
break :preedit .{
|
break :preedit .{
|
||||||
.y = screen.cursor.y,
|
.y = screen.cursor.y,
|
||||||
.x = .{ x, x + preedit_v.width() },
|
.x = preedit_v.range(screen.cursor.x, screen.cols - 1),
|
||||||
};
|
};
|
||||||
} else null;
|
} else null;
|
||||||
|
|
||||||
|
@ -48,4 +48,12 @@ pub const Preedit = struct {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn range(self: *const Preedit, start: usize, max: usize) [2]usize {
|
||||||
|
// If our preedit goes off the end of the screen, we adjust it so
|
||||||
|
// that it shifts left.
|
||||||
|
const end = start + self.width();
|
||||||
|
const offset = if (end > max) end - max else 0;
|
||||||
|
return .{ start -| offset, end -| offset };
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user