<commit_before>import sublime
import sublime_plugin

from Vintageous.vi.utils import (is_at_eol, is_at_hard_eol, is_at_bol,
                      back_one_char, forward_one_char, is_line_empty,
                      is_on_empty_line,)
from Vintageous.vi.constants import regions_transformer


class ClipEndToLine(sublime_plugin.TextCommand):
    def run(self, edit):
        def f(view, s):
            if not is_on_empty_line(self.view, s) and is_at_eol(self.view, s):
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontStayOnEolForward(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_at_eol(self.view, s):
                return forward_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontStayOnEolBackward(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_at_eol(self.view, s) and not self.view.line(s.b).empty():
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontOvershootLineRight(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_on_empty_line(self.view, s):
                return back_one_char(s)
            if is_at_eol(self.view, s):
                return back_one_char(s)
            elif is_at_bol(self.view, s):
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontOvershootLineLeft(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_at_eol(self.view, s):
                return forward_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)<commit_msg>fixes #23 (GH): h and l should not do anything on an empty buffer<commit_after>import sublime
import sublime_plugin

from Vintageous.vi.utils import (is_at_eol, is_at_hard_eol, is_at_bol,
                      back_one_char, forward_one_char, is_line_empty,
                      is_on_empty_line,)
from Vintageous.vi.constants import regions_transformer


class ClipEndToLine(sublime_plugin.TextCommand):
    def run(self, edit):
        def f(view, s):
            if not is_on_empty_line(self.view, s) and is_at_eol(self.view, s):
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontStayOnEolForward(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_at_eol(self.view, s):
                return forward_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontStayOnEolBackward(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if is_at_eol(self.view, s) and not self.view.line(s.b).empty():
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontOvershootLineRight(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if view.size() == 0:
                return s

            if is_on_empty_line(self.view, s):
                return back_one_char(s)

            if is_at_eol(self.view, s):
                return back_one_char(s)
            elif is_at_bol(self.view, s):
                return back_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)


class DontOvershootLineLeft(sublime_plugin.TextCommand):
    def run(self, edit, **kwargs):
        def f(view, s):
            if view.size() > 0 and is_at_eol(self.view, s):
                return forward_one_char(s)
            else:
                return s

        regions_transformer(self.view, f)
{'fraction_non_alphanumeric': 0.0896039603960396, 'fraction_numerical': 0.0009900990099009901, 'mean_word_length': 1.9800884955752212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6151758', 'n_tokens_mistral': 1348, 'n_tokens_neox': 1283, 'n_words': 278}