File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed
Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -274,15 +274,21 @@ def __write_changed_line(
274274 if wlen (newline ) == self .width :
275275 info = CONSOLE_SCREEN_BUFFER_INFO ()
276276 if not GetConsoleScreenBufferInfo (OutHandle , info ):
277- raise WinError ( get_last_error () )
278- win_y = int ( info . dwCursorPosition . Y - info . srWindow . Top )
279- expected = y - self . __offset
280- if win_y == expected + 1 :
281- # Terminal wrapped to next row.
282- self . posxy = 0 , y + 1
277+ err = get_last_error ()
278+ if err == 6 : # ERROR_INVALID_HANDLE
279+ # Best-effort fallback: cursor stays at end-of-line.
280+ self . posxy = self . width , y
281+ else :
282+ raise WinError ( err )
283283 else :
284- # Terminal did not wrap; cursor stays at end-of-line.
285- self .posxy = self .width , y
284+ win_y = int (info .dwCursorPosition .Y - info .srWindow .Top )
285+ expected = y - self .__offset
286+ if win_y == expected + 1 :
287+ # Terminal wrapped to next row.
288+ self .posxy = 0 , y + 1
289+ else :
290+ # Terminal did not wrap; cursor stays at end-of-line.
291+ self .posxy = self .width , y
286292 else :
287293 self .posxy = wlen (newline ), y
288294
You can’t perform that action at this time.
0 commit comments