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

fix log panel not scrolling on initial open #2188

Merged
merged 1 commit into from
Feb 9, 2023
Merged

Conversation

rchl
Copy link
Member

@rchl rchl commented Feb 6, 2023

There was annoying issue with LSP Log Panel that meant that the content didn't scroll when opened initially.

I've experimented a bit with a simple plugin and noticed this this seems like a bug that triggers when:

  • panel view's scroll_past_end setting is set to False
  • and panel is shown with more than a screenfull of content inserted at the same time

The work around is to just trigger view.show(view.sel(), animate=False) after inserting text to scroll the view to the end (or wherever selection was set too if it's not the initial opening).

@rchl
Copy link
Member Author

rchl commented Feb 6, 2023

Used this plugin to test, reproduce and workaround the issue:

import sublime_plugin

PANEL_NAME = 'test-panel'
OUTPUT_PANEL_SETTINGS = {
    'scroll_past_end': False,
}


class CreateTestPanelCommand(sublime_plugin.WindowCommand):
    def run(self) -> None:
        panel = self.window.find_output_panel(PANEL_NAME)
        if not panel:
            panel = self.window.create_output_panel(PANEL_NAME)
            settings = panel.settings()
            for key, value in OUTPUT_PANEL_SETTINGS.items():
                settings.set(key, value)
        self.window.run_command('show_panel', {'panel': 'output.{}'.format(PANEL_NAME)})
        panel.set_read_only(False)
        panel.run_command('insert', {'characters': 'abc\n' * 100})
        # panel.show(panel.sel())
        panel.set_read_only(True)


class DestroyTestPanelCommand(sublime_plugin.WindowCommand):
    def run(self) -> None:
        self.window.destroy_output_panel(PANEL_NAME)

@rchl
Copy link
Member Author

rchl commented Feb 9, 2023

Will get it in as I've been battle testing it for a while.

@rchl rchl merged commit 7fa85a7 into main Feb 9, 2023
@rchl rchl deleted the fix/log-panel-scrolling branch February 9, 2023 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant