diff --git a/docs/changelog.txt b/docs/changelog.txt index 443c4993e..45a3e9a9c 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,6 +37,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ================================================================================ # Future +## Fixes +-@ Console: fixed crash when entering commands on Linux/macOS + ================================================================================ # 0.44.12-alpha1 diff --git a/library/Console-posix.cpp b/library/Console-posix.cpp index 6602b0d0b..da786aaac 100644 --- a/library/Console-posix.cpp +++ b/library/Console-posix.cpp @@ -486,9 +486,10 @@ namespace DFHack int cooked_cursor = raw_cursor; if ((plen+cooked_cursor) >= cols) { - begin = plen+cooked_cursor-cols-1; - len -= plen+cooked_cursor-cols-1; - cooked_cursor -= plen+cooked_cursor-cols-1; + const int text_over = plen + cooked_cursor + 1 - cols; + begin = text_over; + len -= text_over; + cooked_cursor -= text_over; } if (plen+len > cols) len -= plen+len - cols;