Beispiel #1
0
    def testMove_OppositeEndSmaller_DifferentLines_CrossOver_Non0Xpos(self):
        set_text(self.view, 'foo bar\nfoo bar\nfoo bar\n')
        add_selection(self.view, self.R((1, 4), (2, 4)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 2, 'xpos': 4})

        expected = self.R((1, 5), (0, 4))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #2
0
    def testMoveMany_OppositeEndGreater_DifferentLines(self):
        set_text(self.view, ''.join(('foo\n',) * 50))
        add_selection(self.view, self.R((21, 2), (20, 1)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 10, 'xpos': 1})

        expected = self.R((21, 2), (10, 1))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #3
0
    def testMoveBackToSameLine_OppositeEndHasGreaterXpos(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((0, 2), (1, 0)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 0})

        expected = self.R((0, 3), (0, 0))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #4
0
    def testMoveFromEmptyLineToEmptyLine(self):
        set_text(self.view, '\n\n\n')
        add_selection(self.view, make_region_at_row(self.view, row=1, col=0, size=0))

        self.view.run_command('_vi_k', {'mode': MODE_NORMAL, 'count': 1, 'xpos': 0})

        expected = make_region_at_row(self.view, row=0, col=0, size=0)
        self.assertEqual(expected, first_sel(self.view))
Beispiel #5
0
    def testMoveOntoShorterLine(self):
        set_text(self.view, 'foo\nfoo bar')
        add_selection(self.view, make_region_at_row(self.view, row=1, col=5, size=0))

        self.view.run_command('_vi_k', {'mode': MODE_NORMAL, 'count': 1, 'xpos': 5})

        expected = make_region_at_row(self.view, row=0, col=2, size=0)
        self.assertEqual(expected, first_sel(self.view))
Beispiel #6
0
    def testMoveTooFar(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, make_region_at_row(self.view, row=2, col=1, size=0))

        self.view.run_command('_vi_k', {'mode': MODE_NORMAL, 'count': 100, 'xpos': 1})

        expected = make_region_at_row(self.view, row=0, col=1, size=0)
        self.assertEqual(expected, first_sel(self.view))
Beispiel #7
0
    def testMoveOne(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((1, 1), (1, 2)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 2})

        expected = self.R((1, 2), (0, 2))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #8
0
    def testMoveOppositeEndGreaterWithSelOfSize1(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((2, 1), (2, 2)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 2})

        expected = self.R((2, 2), (1, 2))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #9
0
    def testMove_OppositeEndSmaller_DifferentLines_NoCrossOver(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((0, 1), (2, 1)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 1})

        expected = self.R((0, 1), (1, 2))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #10
0
    def testMoveOppositeEndSmallerWithSelOfSize3(self):
        set_text(self.view, 'foobar\nbarfoo\nbuzzfizz\n')
        add_selection(self.view, self.R((1, 1), (1, 4)))

        self.view.run_command('_vi_k', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 3})

        expected = self.R((1, 2), (0, 3))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #11
0
    def testMoveReversedDownFromSameLine(self):
        set_text(self.view, 'abc\nabc\nabc')
        add_selection(self.view, a=6, b=5)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 1})

        target = self.view.text_point(2, 2)
        expected = self.R(5, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #12
0
    def testMoveReversedNoCrossOver(self):
        set_text(self.view, 'abc\nabc\nabc')
        add_selection(self.view, a=10, b=1)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 1})

        target = self.view.text_point(1, 1)
        expected = self.R(10, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #13
0
    def testMoveOntoLongerLine(self):
        set_text(self.view, 'foo\nfoo bar\nfoo bar')
        add_selection(self.view, a=1, b=1)

        self.view.run_command('_vi_j', {'mode': MODE_NORMAL, 'count': 1, 'xpos': 1})

        target = self.view.text_point(1, 1)
        expected = self.R(target, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #14
0
    def testMoveMany(self):
        set_text(self.view, ''.join(('abc\n',) * 60))
        add_selection(self.view, a=1, b=1)

        self.view.run_command('_vi_j', {'mode': MODE_NORMAL, 'count': 50, 'xpos': 1})

        target = self.view.text_point(50, 1)
        expected = self.R(target, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #15
0
    def testMoveFromEmptyLineToEmptyLine(self):
        set_text(self.view, '\n\nbar')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_j', {'mode': MODE_NORMAL, 'count': 1, 'xpos': 0})

        target = self.view.text_point(1, 0)
        expected = self.R(target, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #16
0
    def testMoveTooFar(self):
        set_text(self.view, 'foo\nbar\nbaz')
        add_selection(self.view, a=1, b=1)

        self.view.run_command('_vi_j', {'mode': MODE_NORMAL, 'count': 10000, 'xpos': 1})

        target = self.view.text_point(2, 1)
        expected = self.R(target, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #17
0
    def testMoveOne(self):
        set_text(self.view, 'abc\nabc\nabc')
        add_selection(self.view, a=1, b=2)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL, 'count': 1, 'xpos': 1})

        target = self.view.text_point(1, 2)
        expected = self.R(1, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #18
0
    def testMoveFromEmptyLineToEmptyLine(self):
        set_text(self.view, '\n\nbar')
        add_selection(self.view, a=0, b=1)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL_LINE, 'count': 1, 'xpos': 0})

        target = self.view.text_point(1, 0)
        target = self.view.full_line(target).b
        expected = self.R(0, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #19
0
    def testMoveMany(self):
        set_text(self.view, ''.join(('abc\n',) * 60))
        add_selection(self.view, a=0, b=4)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL_LINE, 'count': 50, 'xpos': 1})

        target = self.view.text_point(50, 0)
        target = self.view.full_line(target).b
        expected = self.R(0, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #20
0
    def testMoveTooFar(self):
        set_text(self.view, 'foo\nbar\nbaz')
        add_selection(self.view, a=0, b=4)

        self.view.run_command('_vi_j', {'mode': MODE_VISUAL_LINE, 'count': 10000, 'xpos': 1})

        target = self.view.text_point(2, 0)
        target = self.view.full_line(target).b
        expected = self.R(0, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #21
0
    def testMoveOntoShorterLine(self):
        set_text(self.view, 'foo bar\nfoo\nbar')
        add_selection(self.view, a=5, b=5)

        self.view.run_command('_vi_j', {'mode': MODE_NORMAL, 'count': 1, 'xpos': 5})

        target = self.view.text_point(1, 0)
        target = self.view.line(target).b - 1
        expected = self.R(target, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #22
0
    def testMoveOne(self):
        set_text(self.view, 'abc\nabc\nabc')
        add_selection(self.view, a=1, b=1)

        self.view.run_command('_vi_j', {'mode': _MODE_INTERNAL_NORMAL, 'count': 1, 'xpos': 1})

        target = self.view.text_point(1, 0)
        target = self.view.full_line(target).b
        expected = self.R(0, target)

        self.assertEqual(expected, first_sel(self.view))
Beispiel #23
0
    def testMoveOne(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((1, 1), (1, 2)))

        self.view.run_command('_vi_k', {
            'mode': MODE_VISUAL,
            'count': 1,
            'xpos': 2
        })

        expected = self.R((1, 2), (0, 2))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #24
0
    def testMoveOppositeEndGreaterWithSelOfSize1(self):
        set_text(self.view, 'foo\nbar\nbaz\n')
        add_selection(self.view, self.R((2, 1), (2, 2)))

        self.view.run_command('_vi_k', {
            'mode': MODE_VISUAL,
            'count': 1,
            'xpos': 2
        })

        expected = self.R((2, 2), (1, 2))
        self.assertEqual(expected, first_sel(self.view))
Beispiel #25
0
    def testMoveFromEmptyLineToEmptyLine(self):
        set_text(self.view, '\n\n\n')
        add_selection(self.view,
                      make_region_at_row(self.view, row=1, col=0, size=0))

        self.view.run_command('_vi_k', {
            'mode': MODE_NORMAL,
            'count': 1,
            'xpos': 0
        })

        expected = make_region_at_row(self.view, row=0, col=0, size=0)
        self.assertEqual(expected, first_sel(self.view))
Beispiel #26
0
    def testMoveMany(self):
        set_text(self.view, 'abc\nabc\nabc')
        add_selection(self.view,
                      make_region_at_row(self.view, row=2, col=1, size=0))

        self.view.run_command('_vi_k', {
            'mode': MODE_NORMAL,
            'count': 2,
            'xpos': 1
        })

        expected = make_region_at_row(self.view, row=0, col=1, size=0)
        self.assertEqual(expected, first_sel(self.view))
Beispiel #27
0
    def testMoveOntoShorterLine(self):
        set_text(self.view, 'foo\nfoo bar')
        add_selection(self.view,
                      make_region_at_row(self.view, row=1, col=5, size=0))

        self.view.run_command('_vi_k', {
            'mode': MODE_NORMAL,
            'count': 1,
            'xpos': 5
        })

        expected = make_region_at_row(self.view, row=0, col=2, size=0)
        self.assertEqual(expected, first_sel(self.view))
    def testSelectsWholeLine(self):
        set_text(self.view, ''.join(('foo bar\nfoo bar\nfoo bar\n',)))
        add_selection(self.view, self.R((1, 2), (1, 2)))

        self.view.run_command('_vi_big_s_motion', {'mode': _MODE_INTERNAL_NORMAL, 'count': 1})
        self.assertEqual(self.R((1, 0), (1, 7)), first_sel(self.view))
Beispiel #29
0
    def testCanMoveInNormalModeWithCount(self):
        set_text(self.view, ''.join(('abc\n', ) * 10))
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_dollar', {'mode': MODE_NORMAL, 'count': 5})
        self.assertEqual(self.R(18, 18), first_sel(self.view))
Beispiel #30
0
    def testCanMoveInVisualModeWithCount(self):
        set_text(self.view, ''.join(('abc\n', ) * 10))
        add_selection(self.view, a=0, b=1)

        self.view.run_command('_vi_dollar', {'mode': MODE_VISUAL, 'count': 5})
        self.assertEqual(self.R(0, 20), first_sel(self.view))
Beispiel #31
0
    def testCanMoveReversedCrossOver(self):
        set_text(self.view, 'foo bar baz')
        add_selection(self.view, a=5, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 5})
        self.assertEqual(self.R(4, 6), first_sel(self.view))
Beispiel #32
0
    def testCanMoveInModeInternalNormal(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_big_g', {'mode': _MODE_INTERNAL_NORMAL, 'count': 1})
        self.assertEqual(self.R(0, 8), first_sel(self.view))
Beispiel #33
0
    def testCanMoveInNormalMode(self):
        set_text(self.view, 'abc\nabc')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_big_g', {'mode': MODE_NORMAL, 'count': 1})
        self.assertEqual(self.R(6, 6), first_sel(self.view))
Beispiel #34
0
    def testCanMoveReversedDifferentLines(self):
        set_text(self.view, 'foo\nbar\n')
        add_selection(self.view, a=5, b=1)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(5, 2), first_sel(self.view))
Beispiel #35
0
    def testCanMoveReversedMinimal(self):
        set_text(self.view, 'abc')
        add_selection(self.view, a=1, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(0, 2), first_sel(self.view))
Beispiel #36
0
    def testCanMoveWithCount(self):
        set_text(self.view, 'foo bar fuzz buzz')
        add_selection(self.view, a=0, b=1)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 10})
        self.assertEqual(self.R(0, 11), first_sel(self.view))
Beispiel #37
0
    def testStopsAtRightEnd(self):
        set_text(self.view, 'abc\n')
        add_selection(self.view, a=0, b=1)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 10000})
        self.assertEqual(self.R(0, 4), first_sel(self.view))
Beispiel #38
0
    def testCanMoveInNormalMode(self):
        set_text(self.view, 'abc')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_NORMAL, 'count': 1})
        self.assertEqual(self.R(1, 1), first_sel(self.view))
Beispiel #39
0
    def testCanMoveInNormalModeWithCount(self):
        set_text(self.view, 'foo bar baz')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_NORMAL, 'count': 10})
        self.assertEqual(self.R(10, 10), first_sel(self.view))
Beispiel #40
0
    def testStopsAtRightEndInNormalMode(self):
        set_text(self.view, 'abc')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_NORMAL, 'count': 10000})
        self.assertEqual(self.R(2, 2), first_sel(self.view))
Beispiel #41
0
    def testCanMoveReversedMinimal(self):
        set_text(self.view, 'abc')
        add_selection(self.view, a=1, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(0, 2), first_sel(self.view))
Beispiel #42
0
    def testStopsAtEolDifferentLinesReversedLargeCount(self):
        set_text(self.view, 'foo\nbar\n')
        add_selection(self.view, a=5, b=3)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 100})
        self.assertEqual(self.R(5, 3), first_sel(self.view))
    def testCanMoveInVisualMode(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=0, b=1)

        self.view.run_command('_vi_big_g', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(0, 8), first_sel(self.view))
Beispiel #44
0
    def testCanMoveReversedCrossOver(self):
        set_text(self.view, 'foo bar baz')
        add_selection(self.view, a=5, b=0)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 5})
        self.assertEqual(self.R(4, 6), first_sel(self.view))
    def testGoToHardEofIfLastLineIsEmpty(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_big_g', {'mode': MODE_NORMAL, 'count': 1})
        self.assertEqual(self.R(8, 8), first_sel(self.view))
Beispiel #46
0
    def testStopsAtEolDifferentLinesReversed(self):
        set_text(self.view, 'foo\nbar\n')
        add_selection(self.view, a=5, b=3)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(5, 3), first_sel(self.view))
Beispiel #47
0
    def testCanMoveInVisualModeWithReversedSelectionCrossOver(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=5, b=4)

        self.view.run_command('_vi_dollar', {'mode': MODE_VISUAL, 'count': 2})
        self.assertEqual(self.R(4, 8), first_sel(self.view))
Beispiel #48
0
    def testGoToHardEofIfLastLineIsEmpty(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=0, b=0)

        self.view.run_command('_vi_big_g', {'mode': MODE_NORMAL, 'count': 1})
        self.assertEqual(self.R(8, 8), first_sel(self.view))
Beispiel #49
0
    def testStaysPutOnEmptyLineInVisualMode(self):
        set_text(self.view, 'abc\n\nabc\n')
        add_selection(self.view, a=4, b=5)

        self.view.run_command('_vi_dollar', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(4, 5), first_sel(self.view))
Beispiel #50
0
    def testCanMoveInModeVisualLine(self):
        set_text(self.view, 'abc\nabc\n')
        add_selection(self.view, a=0, b=4)

        self.view.run_command('_vi_big_g', {'mode': MODE_VISUAL_LINE, 'count': 1})
        self.assertEqual(self.R(0, 8), first_sel(self.view))
Beispiel #51
0
    def testCanMoveReversedDifferentLines(self):
        set_text(self.view, 'foo\nbar\n')
        add_selection(self.view, a=5, b=1)

        self.view.run_command('_vi_l', {'mode': MODE_VISUAL, 'count': 1})
        self.assertEqual(self.R(5, 2), first_sel(self.view))