Home Download Buy Blog Forum Support

scroll_lines command move also the caret

scroll_lines command move also the caret

Postby bizoo on Mon Nov 12, 2012 12:29 pm

When moving the viewing area using scroll_lines command, the caret must not move.

When you have only one caret, the caret follow the viewing area.
when you selection is not empty or do you have more than one caret, the selection(s)/caret doesn't move.

Code: Select all
   { "keys": ["ctrl+up"], "command": "scroll_lines", "args": {"amount": 1.0 } },
   { "keys": ["ctrl+down"], "command": "scroll_lines", "args": {"amount": -1.0 } }

startup, version: 2219 windows x64 channel: nightly
Last edited by bizoo on Mon Jan 28, 2013 12:28 pm, edited 1 time in total.
bizoo
 
Posts: 888
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: scroll_lines command move also the caret

Postby bizoo on Mon Jan 28, 2013 11:40 am

Looks like it's not a bug.
Comparing with others editors, some have the same behavior as ST2, some works as I expected (Eclipse).

I wrote my own plugin to make ST2 works like I want, I post it if someone is interested:
Code: Select all
import sublime, sublime_plugin

class ScrollLinesFixedCommand(sublime_plugin.TextCommand):
    """Must work exactly as builtin scroll_lines command, but without moving the cursor when it goes out of the visible area."""
    def run(self, edit, amount):
        maxy = self.view.layout_extent()[1] - self.view.line_height()
        curx, cury = self.view.viewport_position()
        nexty = min(max(cury - self.view.line_height() * amount, 0), maxy)
        self.view.set_viewport_position((curx, nexty))


Code: Select all
    //scroll_lines fix
    { "keys": ["ctrl+up"], "command": "scroll_lines_fixed", "args": {"amount": 1.0 } },
    { "keys": ["ctrl+down"], "command": "scroll_lines_fixed", "args": {"amount": -1.0 } }
bizoo
 
Posts: 888
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot] and 11 guests