-
Notifications
You must be signed in to change notification settings - Fork 32
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
utils.astring: A couple of strip_console_codes fixes #135
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Lukáš Doktor <[email protected]>
we already set the "index += len(tmp_word) + 1" before we get to this exception so we must not add the tmp_index. Signed-off-by: Lukáš Doktor <[email protected]>
previously we only checked the console_code is found anywhere in the text between the two \x1b and then we blindly removed first N characters. Let's ensure we check the console code regexp from the beginning. Signed-off-by: Lukáš Doktor <[email protected]>
Though I might be misunderstanding but matching only the start of a line doesn't seem to work, ref. #134 (comment) |
these are sometimes generated by kernel, ignore them. Signed-off-by: Lukáš Doktor <[email protected]> Signed-off-by: Sebastian Mitterle <[email protected]>
@ldoktor Sorry for the late response. With this state I get an
|
This is interesting, are you absolutely sure you're using this version of aexpect? The line |
Yes, I'm sure, I just tried again. |
@clebergnu @ldoktor I finally found a reproducer that works also on my laptop and doesn't require VMs. Please check #133 (comment) |
Thanks for the reproducer To address the I'd suggest something like this: diff --git a/aexpect/utils/astring.py b/aexpect/utils/astring.py
index 34936ff..907f4d1 100644
--- a/aexpect/utils/astring.py
+++ b/aexpect/utils/astring.py
@@ -37,7 +37,7 @@ def strip_console_codes(output, custom_codes=None):
output = f"\x1b[m{output}"
console_codes = "^%[G@8]|^\\[[@A-HJ-MPXa-hl-nqrsu\\`]"
console_codes += "|^\\[[\\d;]+[HJKgqnrm]|^#8|^\\([B0UK]|^\\)"
- console_codes += "|^\\[\\?2004[lh]|^c|^\\[!p|^\\]\\d+"
+ console_codes += "|^\\[\\?2004[lh]|^c|^\\[!p|^\\]\\d+|^\\[\\?\\d+h"
if custom_codes is not None and custom_codes not in console_codes:
console_codes += f"|{custom_codes}"
while index < len(output): which keeps the |
From XTerm Control Sequences and xterm.js supported control sequences I deduce that
It raises for me somewhat the question if
|
I noticed the strip_console_code works quite oddly, let's add a selftest and fix the biggest issues.
Anyway the behaviour was here for a long time so this is here just to begin some discussion.
do not merge before a proper discussion!