From 0afd97a502159f7569ecbc7814cc9da287ec625a Mon Sep 17 00:00:00 2001 From: Nick Roberts Date: Thu, 5 Oct 2023 14:11:38 -0400 Subject: [PATCH] Fix #1689 --- CHANGES.md | 2 ++ src/kernel/mbrowse.ml | 12 +++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 0d0d650b38..14fc260816 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -3,6 +3,8 @@ merlin NEXT_VERSION + editor modes - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim) + + merlin binary + - Fix a follow-up issue to the preference of non-ghost nodes introduced in #1660 (#1690, fixes #1689) merlin 4.12 =========== diff --git a/src/kernel/mbrowse.ml b/src/kernel/mbrowse.ml index 7c8b68bfde..9ee7c27f87 100644 --- a/src/kernel/mbrowse.ml +++ b/src/kernel/mbrowse.ml @@ -120,11 +120,13 @@ let compare_locations pos l1 l2 = Location_aux.compare_pos pos l2 with | 0, 0 -> - (* Cursor inside both locations: favor closer to the end *) - if l1.Location.loc_ghost then 1 - else if l2.Location.loc_ghost then -1 - else - Lexing.compare_pos l1.Location.loc_end l2.Location.loc_end + (* Cursor inside both locations: favor non-ghost closer to the end *) + begin match l1.Location.loc_ghost, l2.Location.loc_ghost with + | true, false -> 1 + | false, true -> -1 + | _ -> + Lexing.compare_pos l1.Location.loc_end l2.Location.loc_end + end (* Cursor inside one location: it has priority *) | 0, _ -> t1_first | _, 0 -> t2_first