From cdc9ddb265c38d27f34aea6d2658202cae889a69 Mon Sep 17 00:00:00 2001 From: Akash Yadav Date: Sat, 18 Nov 2023 13:26:31 +0530 Subject: [PATCH] fix(editor/treesitter): occasional crash in TsBracketPairs This is caused by the incorrect order of conditions when checking whether the languageSpec.bracketsQuery can be accessed. --- .../java/io/github/rosemoe/sora/editor/ts/TsBracketPairs.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/TsBracketPairs.kt b/editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/TsBracketPairs.kt index fdc8c570b4..98e2dd3df3 100644 --- a/editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/TsBracketPairs.kt +++ b/editor-treesitter/src/main/java/io/github/rosemoe/sora/editor/ts/TsBracketPairs.kt @@ -47,8 +47,8 @@ class TsBracketPairs(private val tree: TSTree, private val languageSpec: TsLangu } override fun getPairedBracketAt(text: Content, index: Int): PairedBracket? { - if (languageSpec.bracketsQuery.patternCount <= 0 - || !languageSpec.bracketsQuery.canAccess() + if (!languageSpec.bracketsQuery.canAccess() + || languageSpec.bracketsQuery.patternCount <= 0 || !tree.canAccess() ) { return null