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

show_input_panel.on_cancel get called on panel presenting not on closing #6531

Closed
yaroslavyaroslav opened this issue Nov 9, 2024 · 2 comments
Labels

Comments

@yaroslavyaroslav
Copy link

Description of the bug

on_cancel get called on presenting input view rather than on closing it.

Steps to reproduce

Consider code:

       sublime.active_window().show_input_panel(
            'Question:',
            window.settings().get('SOME') or '',  # type: ignore
            lambda user_input: cls.handle_input(user_input, region, text, view, mode, assistant, sheets),
            lambda user_input: cls.save_input(user_input, window),
            on_cancel=cls.check(),
        )

    @classmethod
    def check(cls):
        logger.debug('on_cancel')

Expected behavior

To call on_cancel on esc hit.

Actual behavior

it presents the following output on presenting input view:

DEBUG: show_input_panel hit
DEBUG: on_cancel
DEBUG: user_input: 

and nothing on esc key hit.

Sublime Text build number

4183

Operating system & version

macOS 15.2 beta

(Linux) Desktop environment and/or window manager

No response

Additional information

No response

OpenGL context information

No response

@keith-hall
Copy link
Collaborator

...but the code is invoking the check method and using it's output (None) as the value for the on cancel callback .. remove the parens and try again

@yaroslavyaroslav
Copy link
Author

Ahh, yeah, forgot to add lambda beforehand, thanks.

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

No branches or pull requests

2 participants