I think that cost_incremental_sort() does not account for the limit_tuplesargument properly. Attached is my proposal to fix the problem.
-- Antonin HouskaWeb: https://www.cybertec-postgresql.com