diff --git a/CHANGES.md b/CHANGES.md index a233d0bf7c..5886434622 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ merlin NEXT_VERSION =================== + + merlin binary + - Fix a follow-up issue to the preference of non-ghost nodes introduced in #1660 (#1690, fixes #1689) + editor modes - vim: load merlin when Vim is compiled with +python3/dyn (e.g. MacVim) 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