fix: truncate context logic
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user