[codeface] Re: [PATCH 6/7] Convert Ctags indexing from starting at 1 to starting at 0

  • From: Wolfgang Mauerer <wm@xxxxxxxxxxxxxxxx>
  • To: codeface@xxxxxxxxxxxxx
  • Date: Mon, 17 Nov 2014 21:35:36 +0100


Am 17/10/2014 21:10, schrieb Mitchell Joblin:
> - Ctags indexes the lines starting at 1 but our convention for
>   the source layout starting at 0
> 
> Signed-off-by: Mitchell Joblin <mitchell.joblin.ext@xxxxxxxxxxx>
> ---
>  codeface/VCS.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/codeface/VCS.py b/codeface/VCS.py
> index b16cc33..d918dd7 100644
> --- a/codeface/VCS.py
> +++ b/codeface/VCS.py
> @@ -753,7 +753,7 @@ class gitVCS (VCS):
>              #the lines we want to match start with a commit hash
>              if(self.cmtHashPattern.match( line[0] ) ):
>  
> -               lineNum    = line[2]
> +               lineNum    = str(int(line[2]) - 1)
this converts a string to and int and then back to a string
(which is understandable since you want to perform some
arithmetic)...
>                 commitHash = line[0]
>  
>                 commitLineDict[lineNum] = commitHash
> @@ -986,7 +986,9 @@ class gitVCS (VCS):
>  
>          while(tags.next(entry)):
>              if entry['kind'] in structures:
> -                funcLines[int(entry['lineNumber'])] = entry['name']
> +                ## Ctags indexes starting at 1
> +                lineNum = int(entry['lineNumber']) - 1
... but then, it's converted back to int. So why not just keep int
in the first place?

Cheers, Wolfgang
> +                funcLines[lineNum] = entry['name']
>  
>          # clean up temporary files
>          srcFile.close()
> 

Other related posts: