def test_document_line_edit(workspace): doc = Document('file:///uri', workspace, u'itshelloworld') doc.apply_change({ 'text': u'goodbye', 'range': { 'start': {'line': 0, 'character': 3}, 'end': {'line': 0, 'character': 8} } }) assert doc.source == u'itsgoodbyeworld'
def test_document_empty_edit(workspace): doc = Document('file:///uri', workspace, u'') doc.apply_change({ 'range': { 'start': {'line': 0, 'character': 0}, 'end': {'line': 0, 'character': 0} }, 'text': u'f' }) assert doc.source == u'f'
def test_document_end_of_file_edit(workspace): old = [ "print 'a'\n", "print 'b'\n" ] doc = Document('file:///uri', workspace, u''.join(old)) doc.apply_change({'text': u'o', 'range': { 'start': {'line': 2, 'character': 0}, 'end': {'line': 2, 'character': 0} }}) assert doc.lines == [ "print 'a'\n", "print 'b'\n", "o", ]
def test_document_multiline_edit(workspace): old = [ "def hello(a, b):\n", " print a\n", " print b\n" ] doc = Document('file:///uri', workspace, u''.join(old)) doc.apply_change({'text': u'print a, b', 'range': { 'start': {'line': 1, 'character': 4}, 'end': {'line': 2, 'character': 11} }}) assert doc.lines == [ "def hello(a, b):\n", " print a, b\n" ]