Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output that contains tabs causes problems when replaced by spaces #22

Closed
inkytonik opened this issue Mar 5, 2012 · 2 comments
Closed
Assignees

Comments

@inkytonik
Copy link

It appears that shell command output containing tab characters causes the output end position to be messed up when those tabs are replaced by spaces by Sublime Text 2. I.e., when the

"translate_tabs_to_spaces": true

setting is present for text files (or default).

I can reproduce it on my Mac by running the SublimeREPL | Shell command to get a bash REPL, then running "ls -C /etc". This command uses tabs to separate the columns of output. The output is fine, but then when I do (say) a "w" command next, it thinks that the command starts in the middle of the "ls -C" output rather than at the last prompt.

I think the problem is caused by

        self._output_end += len(unistr)

in ReplView.write() in sublimerepl.py since that statement assumes that the number of characters in the command output is equal to the position adjustment in the buffer, which is not true if tabs have been replaced by spaces when the output is inserted into the buffer.

It seems to be fixed by replacing that line with

        self._output_end = self._view.size()
@ghost ghost assigned wuub Mar 5, 2012
@wuub
Copy link
Owner

wuub commented Mar 5, 2012

I don't even have to reproduce this to know it's there ;) Thanks for the very detailed report!
Although the proposed fix resolves the problem it removes the feature that I use daily. You can start writing next statement[s] while the previous one is still being evaluated and is producing output:

>>> import time
>>> for x in range(10):
...     time.sleep(1)
...     print(x)
... 
0
1
2
3
4
5
print("Hello")
6
7
8
9
>>> Hello
>>> print("Hello2")
Hello2
>>> 

I think overriding "translate_tabs_to_spaces" in ReplView should fix this w/o introducing the described regression.

@inkytonik
Copy link
Author

Ah, I never do that :-)

Overriding the setting should work, I think.

@wuub wuub closed this as completed in 8320d85 Mar 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants