From f81523a4f861813b79b8aed8a641d6d79916d7a1 Mon Sep 17 00:00:00 2001 From: Neil Date: Fri, 22 Aug 2014 21:28:32 +1000 Subject: Bug [#613]. Fix folding when "component' before name. From danselmi. --- lexers/LexVHDL.cxx | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'lexers') diff --git a/lexers/LexVHDL.cxx b/lexers/LexVHDL.cxx index 36307a77f..d917fa547 100644 --- a/lexers/LexVHDL.cxx +++ b/lexers/LexVHDL.cxx @@ -368,8 +368,6 @@ static void FoldNoBoxVHDLDoc( if ( strcmp(s, "architecture") == 0 || strcmp(s, "case") == 0 || - strcmp(s, "component") == 0 || - strcmp(s, "entity") == 0 || strcmp(s, "generate") == 0 || strcmp(s, "loop") == 0 || strcmp(s, "package") ==0 || @@ -384,6 +382,32 @@ static void FoldNoBoxVHDLDoc( } levelNext++; } + } else if ( + strcmp(s, "component") == 0 || + strcmp(s, "entity") == 0 || + strcmp(s, "configuration") == 0 ) + { + if (strcmp(prevWord, "end") != 0) + { // check for instantiated unit by backward searching for the colon. + unsigned pos = lastStart-1; + char chAtPos, styleAtPos; + do{// skip white spaces + styleAtPos = styler.StyleAt(pos); + chAtPos = styler.SafeGetCharAt(pos--); + }while(pos>0 && + (chAtPos == ' ' || chAtPos == '\t' || + chAtPos == '\n' || chAtPos == '\r' || + IsCommentStyle(styleAtPos))); + + // check for a colon (':') before the instantiated units "entity", "component" or "configuration". Don't fold thereafter. + if (chAtPos != ':') + { + if (levelMinCurrentElse > levelNext) { + levelMinCurrentElse = levelNext; + } + levelNext++; + } + } } else if ( strcmp(s, "procedure") == 0 || strcmp(s, "function") == 0) @@ -392,19 +416,19 @@ static void FoldNoBoxVHDLDoc( { // This code checks to see if the procedure / function is a definition within a "package" // rather than the actual code in the body. int BracketLevel = 0; - for(int j=i+1; j levelNext) { levelMinCurrentElse = levelNext; @@ -412,7 +436,7 @@ static void FoldNoBoxVHDLDoc( levelNext++; break; } - if((BracketLevel == 0) && (LocalCh == ';')) + if((BracketLevel == 0) && (chAtPos == ';')) { break; } -- cgit v1.2.3