Skip to content

Commit 4575c51

Browse files
authored
Fix an issue with suggestion button when mispelled word is at the start (#361)
1 parent 3d179ed commit 4575c51

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/npp/NppInterface.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@ std::optional<TextPosition> NppInterface::char_position_from_global_point(int x,
267267
if (WindowFromPoint(p) != hwnd)
268268
return std::nullopt;
269269
ScreenToClient(hwnd, &p);
270-
return send_msg_to_scintilla(SCI_CHARPOSITIONFROMPOINTCLOSE, p.x, p.y);
270+
const auto result = send_msg_to_scintilla(SCI_CHARPOSITIONFROMPOINTCLOSE, p.x, p.y);
271+
if (result < 0) { // -1 is returned if the point is outside the window or not close to any characters
272+
return std::nullopt;
273+
}
274+
return result;
271275
}
272276

273277
TextPosition NppInterface::char_position_from_point(const POINT &pnt) const {

0 commit comments

Comments
 (0)