wuub/SublimeREPL — Issue #9: Carriage return characters in views (Windows)
Author: wuub
Created: 2012-01-27 12:46:34+00:00
State: open

[[ Move from bitbucket ]]

This happens running SublimeText2 on Windows XP:

When using the REPLs Python, Lua, and CMD (at least), carriage return characters ('\r') get written to each line end in the REPL's buffer, and they appear as empty squares.

I've removed this small annoyance, by changing ReplView's "write" method to this:

def write(self, unistr):
"""Writes output from Repl into this view."""
# string is assumet to be already correctly encoded
v = self._view
edit = v.begin_edit()
try:
if sublime.platform() == 'windows':
unistr = unistr.replace('\r\n', '\n')
v.insert(edit, self._output_end, unistr)
self._output_end += len(unistr)
finally:
v.end_edit(edit)
self.scroll_to_end()
The only modification are those two lines checking for Windows, and replacing '\r\n' by '\n'.

Not sure if this is the best way of fixing this, but it works, and makes REPLs prettier.

Thanks for this wonderful plugin!

Oscar.