Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go.py: sort option issues #337

Open
sim642 opened this issue May 6, 2019 · 0 comments
Open

go.py: sort option issues #337

sim642 opened this issue May 6, 2019 · 0 comments
Labels
bug Unexpected problem or unintended behavior

Comments

@sim642
Copy link
Member

sim642 commented May 6, 2019

A week ago I was messing around with the plugins.var.python.go.sort option and noticed some issues/weird things:

  1. The option's help text is incomplete, the source code contains a complete version. The fault seems to be an unnecessary comma here:

    'name = sort by name (or short name), ',

  2. The beginning sort key has extra functionality to ignore a single #:

    scripts/python/go.py

    Lines 250 to 251 in 7f70640

    if re.search(r'^#?' + esc_str, buf['name']) \
    or re.search(r'^#?' + esc_str, buf['short_name']):

    Freenode has channels beginning with ## so it'd make sense to ignore more than one, or possibly even other special symbols.

  3. The number sort key has a very misleading name because it doesn't sort by buffer numbers but rather whether the current searched text exactly matches the buffer's number:

    scripts/python/go.py

    Lines 372 to 374 in 7f70640

    def _sort_match_number(buf):
    """Sort buffers by match on number."""
    return 0 if str(buf['number']) == strinput else 1

    When searching by text, this doesn't happen but it still might be desirable to sort the possible results by their buffer numbers.

  4. The order of sort keys is reverse compared to everything else (buflist.look.sort, fset.look.sort, script.look.sort). Everywhere else, the sort keys are used lexicographically (the most important key is the first, if those are equal sort by second key, etc) but go.py does the sorts in that order:

    scripts/python/go.py

    Lines 387 to 389 in 7f70640

    for key in weechat.config_get_plugin('sort').split(','):
    if key in funcs:
    listbuf = sorted(listbuf, key=funcs[key])

    This actually means that the last sort key is the most important because that's the last one which is sorted by.

@weechatter weechatter added the bug Unexpected problem or unintended behavior label May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants