File tree
Expand file treeCollapse file tree1 file changed
+10
-6
lines changed Expand file treeCollapse file tree1 file changed
+10
-6
lines changed Original file line number | Diff line number | Diff line change |
---|
@@ -119,16 +119,20 @@ async def task(g=None, prompt="--> "):
|
119 | 119 | pt = t # save previous time
|
120 | 120 | t = time.ticks_ms()
|
121 | 121 | if c < 0x20 or c > 0x7E:
|
122 |
| -if c == 0x0A: |
123 |
| -# LF |
| 122 | +if c == 0x0A or c == 0x0D: |
| 123 | +# LF or CR (handle both for raw terminal mode compatibility) |
124 | 124 | if paste:
|
| 125 | +# In paste mode, preserve the actual character |
125 | 126 | sys.stdout.write(b)
|
126 | 127 | cmd += b
|
127 | 128 | continue
|
128 |
| -# If the previous character was also LF, and was less |
129 |
| -# than 20 ms ago, this was likely due to CRLF->LFLF |
130 |
| -# conversion, so ignore this linefeed. |
131 |
| -if pc == 0x0A and time.ticks_diff(t, pt) < 20: |
| 129 | +# Handle various newline sequences to avoid double-execution: |
| 130 | +# - CR+LF (Windows style): ignore LF if it follows CR quickly |
| 131 | +# - LF+LF (PTY double-newline): ignore second LF if it follows quickly |
| 132 | +# - CR+CR (potential double-CR): ignore second CR if it follows quickly |
| 133 | +if ((c == 0x0A and pc == 0x0D) or # LF after CR (CRLF) |
| 134 | +(c == 0x0A and pc == 0x0A) or # LF after LF (double LF) |
| 135 | +(c == 0x0D and pc == 0x0D)) and time.ticks_diff(t, pt) < 20: # CR after CR |
132 | 136 | continue
|
133 | 137 | if curs:
|
134 | 138 | # move cursor to end of the line
|
|
You can’t perform that action at this time.
0 commit comments