From 1c3f493cf924f9c0659e2c590a0cdc4e7fac8833 Mon Sep 17 00:00:00 2001 From: Sergey Semushin Date: Tue, 8 Apr 2025 21:09:55 +0200 Subject: [PATCH] Fix an issue with suggestion button when mispelled word is at the start --- src/npp/NppInterface.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/npp/NppInterface.cpp b/src/npp/NppInterface.cpp index 3e225c9..2ed8db0 100644 --- a/src/npp/NppInterface.cpp +++ b/src/npp/NppInterface.cpp @@ -267,7 +267,11 @@ std::optional NppInterface::char_position_from_global_point(int x, if (WindowFromPoint(p) != hwnd) return std::nullopt; ScreenToClient(hwnd, &p); - return send_msg_to_scintilla(SCI_CHARPOSITIONFROMPOINTCLOSE, p.x, p.y); + const auto result = send_msg_to_scintilla(SCI_CHARPOSITIONFROMPOINTCLOSE, p.x, p.y); + if (result < 0) { // -1 is returned if the point is outside the window or not close to any characters + return std::nullopt; + } + return result; } TextPosition NppInterface::char_position_from_point(const POINT &pnt) const {