dhylands / rshell

Remote Shell for MicroPython
MIT License
955 stars 137 forks source link

Line disappears when pressing backspace multiple times after a space #152

Open k4u5h1k opened 3 years ago

k4u5h1k commented 3 years ago

Do I have a solution?

Yes

Details

Setting self.prompt to a single whitespace self.prompt = ' '

instead of empty string self.prompt = ''

in line 1859 of rshell/main.py fixes the issue completely on OSX

jamesquilty commented 2 years ago

Thanks for this, that single-character addition does indeed fix the "disappearing prompt" problem that's been troubling me! I note that an artefact of this is that there are now two spaces after the prompt: prompt>␣␣. A quick hack that fixes this is to remove the trailing space from line 1863 and adding it to line 1866 in the current HEAD revision on master appears to fix both problems:

     def set_prompt(self):
         if self.stdin == sys.stdin:
-            prompt = PROMPT_COLOR + cur_dir + END_COLOR + '> '
+            prompt = PROMPT_COLOR + cur_dir + END_COLOR + '>'
             if FAKE_INPUT_PROMPT:
                 print(prompt, end='')
-                self.prompt = ''
+                self.prompt = ' '
             else:
                 self.prompt = prompt
         else:

Edit: PR #153 has the same fix for this 🤔

k4u5h1k commented 2 years ago

Yep thats my PR :)