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

sublime_plugin.ListInputHandler docs incomplete #2146

Closed
jrappen opened this issue Jan 4, 2018 · 2 comments
Closed

sublime_plugin.ListInputHandler docs incomplete #2146

jrappen opened this issue Jan 4, 2018 · 2 comments

Comments

@jrappen
Copy link
Contributor

jrappen commented Jan 4, 2018

Add to the docs that preview() in sublime_plugin.ListInputHandler should have two args when using an array of tuples for list_items().


Reference example code here.

@jrappen jrappen mentioned this issue May 6, 2018
15 tasks
OdatNurd added a commit to STealthy-and-haSTy/SnAPI that referenced this issue Nov 1, 2018
Per the below referenced issue, this updates the `preview` method
documentation to point out that in the case where `list_items` returns
a list of tuples instead of a list of regular values, `preview` will be
called with both the text AND the value instead of just the text.

This is as noted by jrappen in:
sublimehq/sublime_text#2146
@FichteFoll
Copy link
Collaborator

I cannot confirm or reproduce this issue on 4074. The following works just fine and only passes the second part of the tuples to the preview funtion:

from html.entities import html5

import sublime_plugin


class InsertHtmlEntityCommand(sublime_plugin.TextCommand):
    def run(self, edit, entity):
        for region in self.view.sel():
            self.view.replace(edit, region, entity)

    def input(self, args):
        return EntityInputHandler()


class EntityInputHandler(sublime_plugin.ListInputHandler):
    def list_items(self):
        return sorted(html5.items())

    def preview(self, value):
        return "Character: {}".format(value)

@FichteFoll
Copy link
Collaborator

The report seems to be based on an incorrect function signature for preview(), where the first parameter was not named self but desc and then not used in the code. Closing as invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants