From 88fa43988acc2389d92ead46a41ff8c7f0608c1a Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 16 Sep 2024 07:25:02 +0100 Subject: Do not return beginning of buffer whenever display to buffer coord fails Use an empty Optional to show that resolution failed and just do not do anything in the mouse event handler in that case. --- src/window.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/window.cc') diff --git a/src/window.cc b/src/window.cc index c5fc44db..6db3a21a 100644 --- a/src/window.cc +++ b/src/window.cc @@ -312,13 +312,13 @@ Optional Window::display_position(BufferCoord coord) const return {}; } -BufferCoord Window::buffer_coord(DisplayCoord coord) const +Optional Window::buffer_coord(DisplayCoord coord) const { if (m_display_buffer.timestamp() != buffer().timestamp() or m_display_buffer.lines().empty()) - return {0, 0}; + return {}; if (coord <= 0_line) - coord = {0,0}; + coord = {}; if ((size_t)coord.line >= m_display_buffer.lines().size()) coord = DisplayCoord{(int)m_display_buffer.lines().size()-1, INT_MAX}; -- cgit v1.2.3