def testToOneWordLineWithLeadingWhitespace(self): set_text(self.view, '\n bar') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b, classes=CLASS_VI_INTERNAL_WORD_START) self.assertEqual(pt, 2)
def testMove2ToEol(self): set_text(self.view, 'foo bar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 7)
def testKeepsLeadingWhitespace(self): set_text(self.view, ''.join(('foo bar\n\t foo bar\nfoo bar\n', ))) add_selection(self.view, self.R((1, 0), (1, 10))) self.view.run_command('_vi_cc_action', {'mode': _MODE_INTERNAL_NORMAL}) self.assertEqual(self.view.substr(self.R(0, self.view.size())), 'foo bar\n\t \nfoo bar\n')
def testDeletesWholeLine(self): set_text(self.view, ''.join(('foo bar\nfoo bar\nfoo bar\n', ))) add_selection(self.view, self.R((1, 0), (1, 7))) self.view.run_command('_vi_cc_action', {'mode': _MODE_INTERNAL_NORMAL}) self.assertEqual(self.view.substr(self.R(0, self.view.size())), 'foo bar\n\nfoo bar\n')
def testMove1FromEmptyLineToLineWithLeadingWhiteSpace(self): set_text(self.view, '\n bar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = words(self.view, r.b, internal=True) self.assertEqual(pt, 1)
def testToWordStart(self): set_text(self.view, '::foo\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 2)
def testToWhitespaceLine(self): set_text(self.view, ':\n \n\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 2)
def testMove2ToWhitespacelineFollowedByLeadingWhitespaceFromWordStart(self): set_text(self.view, 'foo\n \n ccc\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 12)
def testToOneCharWord(self): set_text(self.view, ' a foo bar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 2)
def testMove2ToOneWordLineFromWord(self): set_text(self.view, 'foo\nbar\nccc\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 7)
def testToOneCharWord(self): set_text(self.view, 'foo a bar\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToOneCharLineWithLeadingWhitespace(self): set_text(self.view, 'foo\n a\n\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToEof(self): set_text(self.view, 'foo') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToPunctuationStart(self): set_text(self.view, ' (foo)\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToWhitespaceLine(self): set_text(self.view, 'foo\n \n\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToOneCharLine(self): set_text(self.view, 'foo\na\n\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToOneWordLineWithLeadingWhitespace(self): set_text(self.view, 'foo\n bar\nbaz') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testToWordStart(self): set_text(self.view, ':foo\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 1)
def testMove2ToWhitespaceline(self): set_text(self.view, 'foo\n \nccc\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 10)
def testMove3AndSwallowLastNewlineChar(self): set_text(self.view, '\nfoo\n bar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=3) self.assertEqual(pt, 10)
def testToOneCharLine(self): set_text(self.view, ' \na\n\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 4)
def testMove1ToEol(self): set_text(self.view, 'x\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_ends(self.view, r.b, internal=True, count=1) self.assertEqual(pt, 0)
def testToOneWordLineWithLeadingWhitespace(self): set_text(self.view, '::\n bar\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testToEmptyLine(self): set_text(self.view, '\n\n\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 1)
def testToOneWordLine(self): set_text(self.view, ' \nfoo\nbar') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 4)
def testToOneWordLineWithLeadingWhitespace(self): set_text(self.view, '\n bar') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b, internal=True) self.assertEqual(pt, 2)
def testToWhitespaceLine(self): set_text(self.view, '\n ') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b, classes=CLASS_VI_INTERNAL_WORD_START) self.assertEqual(pt, 3)
def testToWhitespaceLine(self): set_text(self.view, '\n ') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b, internal=True) self.assertEqual(pt, 3)
def testMove2ToLineWithLeadingWhiteSpace(self): set_text(self.view, '\n bar') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, count=2, internal=True) self.assertEqual(pt, 6)
def testToOneCharLine(self): set_text(self.view, '::\na\n\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testToPunctuationStart(self): set_text(self.view, ':: (foo)\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testMove10(self): set_text(self.view, ''.join(('foo bar\n',) * 5)) r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, count=9) self.assertEqual(pt, 36)
def testToEofWithNewline(self): set_text(self.view, 'foo\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_end(self.view, r.b) self.assertEqual(pt, 3)
def testMove1ToWhitespaceLine(self): set_text(self.view, '\n \n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, count=1, internal=True) self.assertEqual(pt, 1)
def testMove2ToLineWithLeadingWhiteSpaceFromWordStart(self): set_text(self.view, 'foo\n\nbar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 5)
def testMove2ToOneWordLine(self): set_text(self.view, '\nfoo\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 5)
def testToOneCharLineWithLeadingWhitespace(self): set_text(self.view, ' \n a\n\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testMove1(self): set_text(self.view, 'foo bar\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b) self.assertEqual(pt, 4)
def testToEofWithNewline(self): set_text(self.view, '::\n') r = self.R((0, 1), (0, 1)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testMove2(self): set_text(self.view, 'foo bar fizz\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, count=2) self.assertEqual(pt, 8)
def testToEof(self): set_text(self.view, ' ') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = next_word_start(self.view, r.b) self.assertEqual(pt, 3)
def testMove2ToWhitespacelineFollowedByLeadingWhitespaceFromWordStart( self): set_text(self.view, 'foo\n \n ccc\n') r = self.R((0, 0), (0, 0)) add_selection(self.view, r) pt = word_starts(self.view, r.b, internal=True, count=2) self.assertEqual(pt, 12)
def testCanMoveInInternalNormalModeWithCount(self): set_text(self.view, 'foo bar baz') add_selection(self.view, a=0, b=0) self.view.run_command('_vi_l', { 'mode': _MODE_INTERNAL_NORMAL, 'count': 10 }) self.assertEqual(self.R(0, 10), first_sel(self.view))
def testCanMoveInInternalNormalModeWithCount(self): set_text(self.view, 'abc\nabc\nabc\nabc\n') add_selection(self.view, a=0, b=0) self.view.run_command('_vi_dollar', { 'mode': _MODE_INTERNAL_NORMAL, 'count': 3 }) self.assertEqual(self.R(0, 12), 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_cc_motion', { 'mode': _MODE_INTERNAL_NORMAL, 'count': 1 }) self.assertEqual(self.R((1, 0), (1, 7)), first_sel(self.view))
def testStopsAtRightEndInInternalNormalMode(self): set_text(self.view, 'abc') add_selection(self.view, a=0, b=0) self.view.run_command('_vi_l', { 'mode': _MODE_INTERNAL_NORMAL, 'count': 10000 }) self.assertEqual(self.R(0, 3), first_sel(self.view))
def testCanRepositionCaret(self): set_text(self.view, 'abc\nxxx\nabc\nabc') add_selection(self.view, self.R((1, 0), (1, 0))) self.view.run_command('ex_move', {'address': '3'}) actual = list(self.view.sel()) expected = [self.R((2, 0), (2, 0))] self.assertEqual(expected, actual)
def testCanMoveToSameLine(self): set_text(self.view, 'abc\nxxx\nabc\nabc') add_selection(self.view, self.R((1, 0), (1, 0))) self.view.run_command('ex_move', {'address': '2'}) actual = self.view.substr(self.R(0, self.view.size())) expected = 'abc\nxxx\nabc\nabc' self.assertEqual(expected, actual)
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))
def testCanDeleteDefaultLineRange(self): set_text(self.view, 'abc\nxxx\nabc\nabc') add_selection(self.view, self.R((1, 0), (1, 0))) self.view.run_command('ex_delete') actual = self.view.substr(self.R(0, self.view.size())) expected = 'abc\nabc\nabc' self.assertEqual(expected, actual)
def testCanMoveInVisualLineModeWithCount(self): set_text(self.view, 'abc\nabc\nabc\nabc\n') add_selection(self.view, a=0, b=4) self.view.run_command('_vi_dollar', { 'mode': MODE_VISUAL_LINE, 'count': 3 }) self.assertEqual(self.R(0, 12), first_sel(self.view))
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))
def testCanMoveInVisualLineModeWithReversedSelection(self): set_text(self.view, 'abc\nabc\nabc\nabc\n') add_selection(self.view, a=4, b=0) self.view.run_command('_vi_dollar', { 'mode': MODE_VISUAL_LINE, 'count': 1 }) self.assertEqual(self.R(4, 1), first_sel(self.view))
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))
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))
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))
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))
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))
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))
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))