stefanoborini / vai

Vai editor. A text based IDE similar to vim, in python.
245 stars 16 forks source link

vai crashes if the last line is deleted with dd #214

Closed syntonym closed 9 years ago

syntonym commented 9 years ago

If the last line in a buffer is deleted with dd vai crashes with the following traceback:

Apologies. Vai has crashed.
---------------------------
Traceback (most recent call last):
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/__init__.py", line 107, in main
    app.exec_()
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vaitk-1.7-py3.4.egg/vaitk/gui/VApplication.py", line 137, in exec_
    self.processEvents(True)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vaitk-1.7-py3.4.egg/vaitk/gui/VApplication.py", line 144, in processEvents
    self._processKeyEvents()
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vaitk-1.7-py3.4.egg/vaitk/gui/VApplication.py", line 300, in _processKeyEvents
    self._processSingleKeyEvent(event)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vaitk-1.7-py3.4.egg/vaitk/gui/VApplication.py", line 322, in _processSingleKeyEvent
    widget.keyEvent(key_event)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/EditArea.py", line 133, in keyEvent
    self._controller.handleKeyEvent(event)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/controllers/EditAreaController.py", line 541, in handleKeyEvent
    new_state = state.handleEvent(event, self._buffer, self._global_state, self._edit_area, self._editor_controller)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/controllers/EditAreaController.py", line 27, in handleEvent
    new_state = cls._handleNonDirectionalKey(event, buffer, global_state, edit_area, editor_controller)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/controllers/EditAreaController.py", line 346, in _handleNonDirectionalKey
    result = command.execute()
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/models/commands/DeleteLineAtCursorCommand.py", line 38, in execute
    document.deleteLine(pos[0])
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/models/TextDocument.py", line 283, in deleteLine
    meta.notifyObservers()
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/models/LineMetaInfo.py", line 79, in notifyObservers
    self.contentChanged.emit()
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vaitk-1.7-py3.4.egg/vaitk/core/VSignal.py", line 25, in emit
    slot(*args, **kwargs)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/controllers/SideRulerController.py", line 51, in updateWidget
    changed_data = self._buffer.document.lineMetaInfo("Change").dataForLines(needed_lines)
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/models/LineMetaInfo.py", line 72, in dataForLines
    return {i: self._data[i-1] for i in lines}
  File "/home/syrn/git/vai/env/lib/python3.4/site-packages/vai-1.7-py3.4.egg/vai/models/LineMetaInfo.py", line 72, in <dictcomp>
    return {i: self._data[i-1] for i in lines}
IndexError: list index out of range

How to reproduce (chars to input):

vai
ifoo<esc>dd
stefanoborini commented 9 years ago

strange. I thought I fixed it.

stefanoborini commented 9 years ago

On it.