From 52562967d157a941c40853d1a550d9c042528373 Mon Sep 17 00:00:00 2001 From: dimm Date: Thu, 26 Feb 2026 21:27:29 +0300 Subject: [PATCH] Fixed an issue with static variable detection --- autoload/omni/cpp/items.vim | 8 +++++++- doc/omnicppcomplete.txt | 8 ++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/autoload/omni/cpp/items.vim b/autoload/omni/cpp/items.vim index b943ad4..4794832 100644 --- a/autoload/omni/cpp/items.vim +++ b/autoload/omni/cpp/items.vim @@ -1,6 +1,6 @@ " Description: Omni completion script for cpp files " Maintainer: Vissale NEANG -" Last Change: 26 sept. 2007 +" Last Change: 26 feb. 2026 " Build the item list of an instruction " An item is an instruction between a -> or . or ->* or .* @@ -297,6 +297,12 @@ function! s:GetTypeInfoOfVariable(contextStack, szVariable, bSearchDecl) return result endif + " In the case of 'struct ... {} static variable;' the 'typeref' contains a trailing space. + " Tested with Universal Ctags 6.2.1 + if has_key(tagItem, 'typeref') + let tagItem.typeref = substitute(tagItem.typeref, '\s\+$', '', '') + endif + let szCmdWithoutVariable = substitute(omni#cpp#utils#ExtractCmdFromTagItem(tagItem), '\C\<'.a:szVariable.'\>.*', '', 'g') let tokens = omni#cpp#tokenizer#Tokenize(omni#cpp#utils#GetCodeFromLine(szCmdWithoutVariable)) let result = omni#cpp#utils#CreateTypeInfo(omni#cpp#utils#ExtractTypeInfoFromTokens(tokens)) diff --git a/doc/omnicppcomplete.txt b/doc/omnicppcomplete.txt index b11e006..e86658b 100644 --- a/doc/omnicppcomplete.txt +++ b/doc/omnicppcomplete.txt @@ -2,9 +2,9 @@ *omnicppcomplete* Author: Vissale NEANG (fromtonrouge AT gmail DOT com) -Last Change: 26 sept. 2007 +Last Change: 26 feb. 2026 -OmniCppComplete version 0.41 +OmniCppComplete version 0.42 For Vim version 7.0 and above @@ -883,6 +883,10 @@ templates. That's why the script does not handle templates. ============================================================================== 8. History~ *omnicpp-history* +Version 0.42 + - Fixed an issue with static variable detection when using Universal + Ctags (6.2.1). + Version O.41 - It's recommended to update ctags to version 5.7 or higher - The plugin is now activated for C files