Skip to content

Commit

Permalink
fix(lang-treesitter): new AST is unexpectedly edited by main thread s…
Browse files Browse the repository at this point in the history
…ometimes
  • Loading branch information
Rosemoe committed Feb 7, 2025
1 parent 3783c7b commit f67c11f
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ open class TsAnalyzeManager(val languageSpec: TsLanguageSpec, var theme: TsTheme
if (thread == this && messageQueue.isEmpty()) {
val oldTree = (styles.spans as LineSpansGenerator?)?.safeTree
val newTree = SafeTsTree(tree!!.copy())
styles.spans = LineSpansGenerator(
val newSpans = LineSpansGenerator(
newTree,
reference!!.lineCount,
reference!!.reference,
Expand All @@ -190,6 +190,7 @@ open class TsAnalyzeManager(val languageSpec: TsLanguageSpec, var theme: TsTheme
val oldBlocks = styles.blocks
updateCodeBlocks()
currentReceiver?.setStyles(this@TsAnalyzeManager, styles) {
styles.spans = newSpans
oldTree?.close()
if (oldBlocks != null) {
ObjectAllocator.recycleBlockLines(oldBlocks)
Expand Down

0 comments on commit f67c11f

Please # to comment.