Skip to content

Commit

Permalink
Temp limit TreeSitter to 6000 lines of code max.
Browse files Browse the repository at this point in the history
* Hotfix to resolve issues with the syntax highlighter, which
  becomes unstable with very large files, need to dig into
  TreeSitter to find the culprit of this unstability before we
  can increase this threshold higher.
  • Loading branch information
furby-tm committed Aug 9, 2024
1 parent 6c2c886 commit 2bbda9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 13 additions & 5 deletions Sources/Kraken/IO/Universal/KIO.USD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,17 @@ public extension Kraken.IO

var contents = ""
context.stage.exportToString(&contents, addSourceFileComment: false)
context.usda = contents
context.usda = String(contents.prefix(6000))
return
}
context.usda = string
context.usda = String(string.prefix(6000))
}

public func fileWrapper(snapshot _: Kraken.IO.USD.Context, configuration _: WriteConfiguration) throws -> FileWrapper
{
context.stage.exportToString(&context.usda, addSourceFileComment: false)
var contents = ""
context.stage.exportToString(&contents, addSourceFileComment: false)
context.usda = String(contents.prefix(6000))

return .init(regularFileWithContents: context.usda.data(using: .utf8)!)
}
Expand Down Expand Up @@ -122,7 +124,10 @@ public extension Kraken.IO.USD
stage = Usd.Stage.open(fileURL.path)

Kraken.IO.Stage.manager.save(&stage)
stage.exportToString(&usda, addSourceFileComment: false)

var contents = ""
stage.exportToString(&contents, addSourceFileComment: false)
usda = String(contents.prefix(6000))
}

public func open(fileURL: URL)
Expand All @@ -131,7 +136,10 @@ public extension Kraken.IO.USD
stage = Usd.Stage.open(fileURL.path)

Kraken.IO.Stage.manager.save(&stage)
stage.exportToString(&self.usda, addSourceFileComment: false)

var contents = ""
stage.exportToString(&contents, addSourceFileComment: false)
usda = String(contents.prefix(6000))
}
}
}
Expand Down
8 changes: 0 additions & 8 deletions Sources/Kraken/UI/Editors/KUI.CodeEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ public extension Kraken.UI
Task
{
Kraken.IO.Stage.manager.reloadAndSave(stage: &C.context.stage)

var contents = ""
C.context.stage.exportToString(&contents, addSourceFileComment: false)

if C.context.usda != contents
{
C.context.usda = contents
}
}
}
.onAppear
Expand Down

0 comments on commit 2bbda9b

Please sign in to comment.