EugeneManushkin / CtagsSourceNavigator

Reworked Ctags Source Navigator plugin based on source code v0.93 beta compatible with Far3
GNU General Public License v2.0
16 stars 0 forks source link

Incorrect rerpesentation of search result in Far Menu (incorrect string shortening) #21

Closed sakkada closed 6 years ago

sakkada commented 6 years ago

When name of file, containing searched tag, is too long, some times shortening of such filenames works incorrectly:

  1. File names are correctly shortened (python, django project, tag "Permission", looking for classes "PermissionDenied"):

    ╔══════════════════════════════════════════════════ [Filter: Permission] ══════════════════════════════════════════════════╗
    ║  c:Permission              class Permission(models. .../dreamfinder/.env/Lib/site-packages/django/contrib/auth/models.py ║
    ║  c:PermissionDenied        class PermissionDenied(E ...ango/dreamfinder/.env/Lib/site-packages/django/core/exceptions.py ║ - 1st
    ║  c:PermissionDenied        class PermissionDenied(A ...o/dreamfinder/.env/Lib/site-packages/rest_framework/exceptions.py ║ - 2nd
    ║  c:PermissionDenied        class PermissionDenied(E C:/django/dreamfinder/project/project/apps/api/exceptions.py         ║ - 3rd
    ║  v:PermissionError         PermissionError = None   ...nder/.env/Lib/site-packages/pip/_vendor/pkg_resources/__init__.py ║
    ║  v:PermissionError         PermissionError = None   ...ango/dreamfinder/.env/Lib/site-packages/pkg_resources/__init__.py ║
    ║  c:PermissionManager       class PermissionManager( .../dreamfinder/.env/Lib/site-packages/django/contrib/auth/models.py ║
    ║  c:PermissionRequiredMixin class PermissionRequired .../dreamfinder/.env/Lib/site-packages/django/contrib/auth/mixins.py ║
    ║  c:PermissionsMixin        class PermissionsMixin(m .../dreamfinder/.env/Lib/site-packages/django/contrib/auth/models.py ║
    ╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝
  2. File names in this case are shortened incorrectly (1st filename is incorrectly represented, only extension):

    ╔═════════════════════════════════════════════════ [Filter: PermissionD] ══════════════════════════════════════════════════╗
    ║  c:PermissionDenied class PermissionDenied(E ...py                                                                       ║ - 1st
    ║  c:PermissionDenied class PermissionDenied(A ...:/django/dreamfinder/.env/Lib/site-packages/rest_framework/exceptions.py ║ - 2nd
    ║  c:PermissionDenied class PermissionDenied(E C:/django/dreamfinder/project/project/apps/api/exceptions.py                ║ - 3rd
    ╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════╝

Also, it will be very good feature, showing full information from tags, multilined by TAB char, file for selected tag in Menu (for example by F4, with possibility to edit/copy desired parts of string).

EugeneManushkin commented 6 years ago

Dear Murat! I'm very glad that you decided to help me to develop this project by submitting the issue and providing your vision of a new feature, thanks! I consider this as my first T4 case )

Did you use option "Search name in opened file" or it was "Search name in entire repository" ?

EugeneManushkin commented 6 years ago

Also please provide plugin build number

sakkada commented 6 years ago

Hello Eugene. Thank you very much for your reply and for very usefull plugin!

  1. First case is result of "Search name in entire repository" (after this menu item was called, "Permission" was typed).
  2. Second case is result of call of both "Open declaration" or "Search name in entire repository". On the screenshop result of "Search name in entire repository", result of "Open declaration" is very similar and look like:
╔════════════════════════════════════════════════  [Begin type or Ctrl+V] ═════════════════════════════════════════════════╗
║  c:PermissionDenied class PermissionDenied(E ...py                                                                       ║
║  c:PermissionDenied class PermissionDenied(A ...:/django/dreamfinder/.env/Lib/site-packages/rest_framework/exceptions.py ║
║  c:PermissionDenied class PermissionDenied(E C:/django/dreamfinder/project/project/apps/api/exceptions.py                ║
╚═════════════════════════════════════════════════════ Items count:3 ══════════════════════════════════════════════════════╝

Content of .tags file for there lines are:

PermissionDenied    C:/django/dreamfinder/.env/Lib/site-packages/django/core/exceptions.py  /^class PermissionDenied(Exception):$/;"    c   line:72 language:Python inherits:Exception
PermissionDenied    C:/django/dreamfinder/.env/Lib/site-packages/rest_framework/exceptions.py   /^class PermissionDenied(APIException):$/;" c   line:176    language:Python inherits:APIException
PermissionDenied    C:/django/dreamfinder/project/project/apps/api/exceptions.py    /^class PermissionDenied(ErrorCodeMixin, exceptions.PermissionDenied):$/;"  c   line:48 language:Python inherits:ErrorCodeMixin, exceptions.PermissionDenied

Note: I found that if content of .tags file (generated by another way) is:

PermissionDenied    .env/Lib/site-packages/django/core/exceptions.py    /^class PermissionDenied(Exception):$/;"    c   line:72 language:Python inherits:Exception
PermissionDenied    .env/Lib/site-packages/rest_framework/exceptions.py /^class PermissionDenied(APIException):$/;" c   line:176    language:Python inherits:APIException
PermissionDenied    project/project/apps/api/exceptions.py  /^class PermissionDenied(ErrorCodeMixin, exceptions.PermissionDenied):$/;"  c   line:48 language:Python inherits:ErrorCodeMixin, exceptions.PermissionDenied

then result of each functions, shown above will be correct:

╔═════════════════════════════════════════════  [Begin type or Ctrl+V] ═════════════════════════════════════════════╗
║  c:PermissionDenied class PermissionDenied(E c:\...o\dreamfinder\.env/Lib/site-packages/django/core/exceptions.py ║
║  c:PermissionDenied class PermissionDenied(A c:\...reamfinder\.env/Lib/site-packages/rest_framework/exceptions.py ║
║  c:PermissionDenied class PermissionDenied(E c:\django\dreamfinder\project/project/apps/api/exceptions.py         ║
╚══════════════════════════════════════════════════ Items count:3 ══════════════════════════════════════════════════╝

Hope, this will help to solve the problem of very long filenames.

Versions: Far – 3.0 build 4949 x86, ctags – 2.1.0.12.

Thank you for this plugin again, Eugene!

EugeneManushkin commented 6 years ago

Reproduced on tags file with '/' path separator. Invalid handling forward slashes in TrimFilename:

  int ri=file.RIndex("\\")+1; // what if '/' is used instead of '\\' ?
  if(file.Length()-ri+3>maxlength)
  {
    return "..."+file.Substr(file.Length()-maxlength-3);

Edit: The problem was in fact in file.Substr(file.Length()-maxlength-3). Given: maxlength==69, file.Length() == 70, ri == 0, then file.Length()-maxlength-3 == 70 - 69 - 3 == -2

EugeneManushkin commented 6 years ago

tags with reproduced issue attached: django.zip

EugeneManushkin commented 6 years ago

Fixed in build_2.1.0.15 Issue with suggested feature is created #22 @sakkada , please update your plugin with build 2.1.0.15, you may download it from release page

sakkada commented 6 years ago

Thank you very much for your quick update and for making my favorite file manager really better (for me, actually, far is more than just a fm, most of things, which I do on my pc I'm doing with it), I've already upgraded your plugin to latest version ) After a couple week of usage, hope, I'll write you new enhancements.