From 18a632da9d0c6a6d1f369dae82cc07acd88c0079 Mon Sep 17 00:00:00 2001 From: Ricky Zhou Date: Fri, 10 Oct 2025 19:44:05 -0700 Subject: [PATCH] Make findMatchingBracket swap between start and end brackets. matchBracket returns an array containing start and end ranges for brackets. Previously, findMatchingBracket (corresponding to vim's % motion) would always jump to the end bracket. Fix it to jump to the bracket whose range does not contain the current cursor position. --- src/cm_adapter.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cm_adapter.ts b/src/cm_adapter.ts index 9446ad2..cf42afa 100644 --- a/src/cm_adapter.ts +++ b/src/cm_adapter.ts @@ -969,7 +969,11 @@ class CMAdapter { } return { - to: toCmPos(res[1].getStartPosition()), + to: toCmPos( + res[0].containsPosition(mPos) + ? res[1].getStartPosition() + : res[0].getStartPosition() + ), }; }