diff --git a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp index 493ded3d9..e4561c0bf 100644 --- a/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp +++ b/src/tools/ecode/plugins/lsp/lspdocumentclient.cpp @@ -268,7 +268,7 @@ void LSPDocumentClient::highlight() { const Uint32 deltaLine = data[i]; const Uint32 deltaStart = data[i + 1]; const Uint32 len = data[i + 2]; - const Uint32 type = data[i + 3]; + const int type = data[i + 3]; // const Uint32 mod = data[i + 4]; currentLine += deltaLine; @@ -279,9 +279,14 @@ void LSPDocumentClient::highlight() { } auto& line = tokenizerLines[currentLine]; - const auto& ltype = caps.legend.tokenTypes[type]; - line.tokens.push_back( - { semanticTokenTypeToSyntaxType( ltype, mDoc->getSyntaxDefinition() ), start, len } ); + if ( type >= 0 && type < (int)caps.legend.tokenTypes.size() ) { + const auto& ltype = caps.legend.tokenTypes[type]; + line.tokens.push_back( + { semanticTokenTypeToSyntaxType( ltype, mDoc->getSyntaxDefinition() ), start, + len } ); + } else { + line.tokens.push_back( { "normal", start, len } ); + } line.hash = mDoc->line( currentLine ).getHash(); line.updateSignature(); diff --git a/src/tools/ecode/plugins/lsp/lspprotocol.hpp b/src/tools/ecode/plugins/lsp/lspprotocol.hpp index 70d95609b..324302f36 100644 --- a/src/tools/ecode/plugins/lsp/lspprotocol.hpp +++ b/src/tools/ecode/plugins/lsp/lspprotocol.hpp @@ -571,13 +571,13 @@ struct LSPApplyWorkspaceEditResponse { struct LSPSemanticTokensEdit { Uint32 start = 0; Uint32 deleteCount = 0; - std::vector data; + std::vector data; }; struct LSPSemanticTokensDelta { std::string resultId; std::vector edits; - std::vector data; + std::vector data; }; } // namespace ecode