Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

Fix code location when reading history from a file #3416

Closed d-torrance closed 2 months ago

d-torrance commented 3 months ago

At startup, we use a new compiled function (historyLength(), which returns the value of readline's history_length variable) to determine how many lines of history we've saved from previous sessions. We add this value to the line numbers of any code from stdio when calling code so we get the correct lines back when calling getHistory.

Before

i1 : f = x -> x^2;

i2 : code f

o2 = stdio:1:6-1:11: --source code:
     -- This is the beginning of your Macaulay2 log stored at /home/profzoom/.Macaulay2/history.m2

After

i1 : f = x -> x^2;

i2 : code f

o2 = stdio:1:4-1:12: --source code:
     f = x -> x^2;

Closes: #3415

mahrud commented 2 months ago

Do we have a mechanism to test this? Not sure how exactly to test readline ...