python: Fix resetting scope on anonymous blocks
The previous fix, coming from [CTags bug #1988026], was incorrect if the parent was not a root-level element, as it checked the level name (unqualified) against the parent name (qualified). However, there is no need to check the level name, all what counts is the indentation level itself: if it's smaller than an existing level, it ends it. This fixes [CTags bug #356]. [CTags bug #1988026]: https://sourceforge.net/p/ctags/bugs/227/ [CTags bug #356]: https://sourceforge.net/p/ctags/bugs/356/ X-Universal-CTags-Commit-ID: ab91e6e1ae84b80870a1e8712fc7f3133e4b5542
This commit is contained in:
parent
935c389f28
commit
d75598cc48
@ -463,10 +463,8 @@ static boolean constructParentString(NestingLevels *nls, int indent,
|
|||||||
return is_class;
|
return is_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether parent's indentation level is higher than the current level and
|
/* Check indentation level and truncate nesting levels accordingly */
|
||||||
* if so, remove it.
|
static void checkIndent(NestingLevels *nls, int indent)
|
||||||
*/
|
|
||||||
static void checkParent(NestingLevels *nls, int indent, vString *parent)
|
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
NestingLevel *n;
|
NestingLevel *n;
|
||||||
@ -474,14 +472,10 @@ static void checkParent(NestingLevels *nls, int indent, vString *parent)
|
|||||||
for (i = 0; i < nls->n; i++)
|
for (i = 0; i < nls->n; i++)
|
||||||
{
|
{
|
||||||
n = nls->levels + i;
|
n = nls->levels + i;
|
||||||
/* is there a better way to compare two vStrings? */
|
if (n && indent <= n->indentation)
|
||||||
if (n && strcmp(vStringValue(parent), vStringValue(n->name)) == 0)
|
|
||||||
{
|
{
|
||||||
if (indent <= n->indentation)
|
/* truncate levels */
|
||||||
{
|
nls->n = i;
|
||||||
/* remove this level by clearing its name */
|
|
||||||
vStringClear(n->name);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,7 +743,7 @@ static void findPythonTags (void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkParent(nesting_levels, indent, parent);
|
checkIndent(nesting_levels, indent);
|
||||||
|
|
||||||
/* Find global and class variables */
|
/* Find global and class variables */
|
||||||
variable = findVariable(line);
|
variable = findVariable(line);
|
||||||
|
@ -235,6 +235,7 @@ test_sources = \
|
|||||||
pure_elem.f95 \
|
pure_elem.f95 \
|
||||||
py_constructor_arglist.py \
|
py_constructor_arglist.py \
|
||||||
py-skipped-string.py \
|
py-skipped-string.py \
|
||||||
|
python-anonymous-nestlevel_ctags-bug-356.py \
|
||||||
qualified_types.f90 \
|
qualified_types.f90 \
|
||||||
random.sql \
|
random.sql \
|
||||||
readlob.sql \
|
readlob.sql \
|
||||||
|
6
tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py
Normal file
6
tests/ctags/python-anonymous-nestlevel_ctags-bug-356.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
class Testclass():
|
||||||
|
def main(self):
|
||||||
|
variable = True
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
module_level_attribute = True
|
@ -0,0 +1,4 @@
|
|||||||
|
# format=tagmanager
|
||||||
|
TestclassÌ1Ö0
|
||||||
|
mainÌ128Í(self)ÎTestclassÖ0
|
||||||
|
module_level_attributeÌ16384Ö0
|
Loading…
x
Reference in New Issue
Block a user