Exemplo n.º 1
0
 def test_SearchBackwardClearsPreviousReferencesWithOffsets(self):
     parsed = parse_command_line('.+10?foo?')
     self.assertEqual(
         parsed.line_range.start,
         [TokenDot(),
          TokenOffset([10]),
          TokenSearchBackward('foo')])
     self.assertEqual(parsed.line_range.end, [])
Exemplo n.º 2
0
 def testCanScanDotOffsetSearchForward(self):
     scanner = Scanner(".+10/foobar/")
     tokens = list(scanner.scan())
     self.assertEqual([
         TokenDot(),
         TokenOffset([10]),
         TokenSearchForward('foobar'),
         TokenEof()
     ], tokens)
     self.assertEqual(12, scanner.state.position)
Exemplo n.º 3
0
    def resolve(self, view):
        '''
        Returns a Sublime Text range representing the Vim line range that the
        ex command should operate on.
        '''
        start = self.resolve_line_reference(view, self.start or [TokenDot()])

        if not self.separator:
            if start == -1:
                return R(-1, -1)

            if len(self.start) == 1 and isinstance(self.start[0],
                                                   TokenPercent):
                return R(0, view.size())

            return view.full_line(view.text_point(start, 0))

        new_start = start if self.separator == ';' else 0
        end = self.resolve_line_reference(view,
                                          self.end or [TokenDot()],
                                          current=new_start)

        return view.full_line(
            R(view.text_point(start, 0), view.text_point(end, 0)))
Exemplo n.º 4
0
 def testCanScanNegativeOffset(self):
     scanner = Scanner(".-100")
     tokens = list(scanner.scan())
     self.assertEqual([TokenDot(), TokenOffset([-100]), TokenEof()], tokens)
Exemplo n.º 5
0
 def testCanScanDot(self):
     scanner = Scanner(".")
     tokens = list(scanner.scan())
     self.assertEqual([TokenDot(), TokenEof()], tokens)
Exemplo n.º 6
0
 def test_SearchForwardClearsPreviousReferences(self):
     parsed = parse_command_line('./foo/')
     self.assertEqual(parsed.line_range.start,
                      [TokenDot(), TokenSearchForward('foo')])
     self.assertEqual(parsed.line_range.end, [])
Exemplo n.º 7
0
 def test_CanParseDotWithOffset(self):
     parsed = parse_command_line('.+10')
     self.assertEqual(parsed.line_range.start,
                      [TokenDot(), TokenOffset([10])])
     self.assertEqual(parsed.line_range.end, [])
Exemplo n.º 8
0
 def test_CanParseDotAsStartLine(self):
     parsed = parse_command_line('.')
     self.assertEqual(parsed.line_range.start, [TokenDot()])
     self.assertEqual(parsed.line_range.end, [])
Exemplo n.º 9
0
 def test_CanParseSmicolonDot(self):
     parsed = parse_command_line(';.')
     self.assertEqual(parsed.line_range.start, [])
     self.assertEqual(parsed.line_range.end, [TokenDot()])
     self.assertEqual(parsed.line_range.separator, TokenSemicolon())
Exemplo n.º 10
0
 def test_CanParseCommaDot(self):
     parsed = parse_command_line(',.')
     self.assertEqual(parsed.line_range.separator, TokenComma())
     self.assertEqual(parsed.line_range.start, [])
     self.assertEqual(parsed.line_range.end, [TokenDot()])