fix: truncate context logic
C++ / fmt (pull_request) Successful in 4s
C++ / build (pull_request) Failing after 2m6s
C++ / clang-tidy (pull_request) Failing after 2m5s
JS/TS / fmt (pull_request) Failing after 3m8s
Python / static (pull_request) Successful in 24s
Python / verify (pull_request) Successful in 1m21s
JS/TS / lint (pull_request) Successful in 5m10s
Rust / fmt (pull_request) Successful in 30s
Rust / build (pull_request) Successful in 56s
Rust / clippy (pull_request) Successful in 46s

This commit is contained in:
2026-09-04 02:20:37 +02:00
parent 34dde4bbfb
commit cd3da1941b
15 changed files with 238 additions and 126 deletions
+5 -6
View File
@@ -37,10 +37,10 @@ class CodeHighlighter : public QObject {
private:
struct State {
bool bad = false; // permanent failure, do not retry
bool bad = false;
void* lib = nullptr;
const void* lang = nullptr; // const TSLanguage*
void* query = nullptr; // TSQuery*
const void* lang = nullptr;
void* query = nullptr;
};
[[nodiscard]] static const QHash<QString, QString>& aliases();
@@ -59,15 +59,14 @@ class CodeHighlighter : public QObject {
const QVariantList& spans) const;
struct SpanCacheEntry {
QString code; // re-compared on lookup; a hash collision can
// never deliver the wrong spans
QString code;
QVariantList spans;
};
mutable QHash<QString, std::shared_ptr<const State>> m_states;
mutable QMutex m_stateMutex;
mutable QHash<QString, SpanCacheEntry> m_spanCache;
mutable QStringList m_spanCacheOrder; // LRU order, oldest first
mutable QStringList m_spanCacheOrder;
mutable int m_spanCacheBytes = 0;
mutable QMutex m_cacheMutex;
static CodeHighlighter* s_instance;