code: def _collapse_cursor(self, parts):
          
  
          final_parts = []
          for part in parts:
  
              # Throw out empty string tokens ("")
              if not part:
                  continue
  
              # Go back, deleting every token in the last 'line'
              if part == CursorMoveUp:
                  if final_parts:
                      final_parts.pop()
  
                  while final_parts and '\n' not in final_parts[-1]:
                      final_parts.pop()
  
                  continue
  
              # Otherwise, just pass this token forward
              final_parts.append(part)
  
          return final_parts
docs: Act on any CursorMoveUp commands by deleting preceding tokens