When you have a billion errors, the bottom ones usually result from the top ones, so you only need to resolve those. But the output window is always scrolled to the very bottom, which is not very helpful, since I have to grab my mouse every time I Ctrl+B. Is there a setting to make it scroll to the top automatically?
How to automatically scroll build output to the top?
You can easily create a plugin to scroll to the top. Select Tools > Developer > New Plugin… and paste:
import sublime_plugin
class BuildScollTopCommand(sublime_plugin.WindowCommand):
def run(self):
v = self.window.find_output_panel("exec")
if not v:
return
v.run_command("move_to", {"to": "bof"})
Then add a keybinding
{
"keys": ["ctrl+k", "ctrl+home"],
"command": "build_scoll_top",
},
Now just press the keybinding to scroll to the top. Not sure how to do it automatically, because I don’t know how to listen to the finish of the build.
Packages/Default/exec.py
runs the append
command with the argument "scroll_to_end": true
- not that I’d advocate such a thing, but as an alternative to listening to the finish of the build, one could change this argument’s value to false and presumably it would never scroll
@kingkeith Yup that worked! Thanks @r-stein too, but the other answer makes it automatic
I’ve explored the Default packages quite a lot
as you are overriding a file in the Default package, I highly recommend installing OverrideAudit so that you don’t forget to undo/redo your change when the next ST build is released, otherwise you could experience odd behavior due to having an outdated plugin file
I am using PackageResourceViewer
, which to my knowledge saves the changes in the User
folder, so it shouldn’t be a problem.
Unless you specifically use save as
to save a file that you’ve opened with PackageResourceViewer
as a different name, the files that it opens will save as an override (i.e. within a folder named after the package, not your User
folder).
Does this still work for you guys?
These days, changing 'scroll_to_end': True
to 'scroll_to_end': False
in exec.py
does not seem to prevent the Build Results panel from scrolling all the way to the bottom.
It does however prevent it from scrolling horizontally to the right if there is a long line and "word_wrap": false
is set in the Build System. But that’s not nearly as useful as preventing vertical scrolling!
I’m also having trouble getting "scroll_to_end": False
to leave the scrolling alone when manually appending text to a panel. I see that this code was touched in July 2021, based on this note in the 4113 release notes:
Fixed the append command’s
scroll_to_end
parameter sometimes not working
So that’s probably what was wrong at the time of this post. However, it’s still not working for me on current release build 4143. I have a WindowCommand
with this code:
# Setup
self.panel = self.window.create_output_panel("exec")
self.window.run_command("show_panel", {"panel": "output.exec"})
# Repeated line writes
# ...
for line in lines:
self.panel.run_command("append", {"characters": line, "scroll_to_end": False})
But the panel opens with only the last line visible, at the very top of the panel. All previous lines are scrolled off the top of the viewport. This happens even when the lines are short and require no wrapping.
UPDATE: My problem was that I had named my panel "exec"
. If you use any other name, "scroll_to_end": False
works as expected.