Sublime Forum

Limit undo stack size option

#1

I was reading this post, in which John confirmed the undo stack size is illimited.
This made me think, why not have a new option in the preferences? I was thinking it could be called undo_stack_size. It should accept “unlimited” (or “infinite”, your choice) and integers as values (example with integers: if it’s set to 20 then sublime will track the first 20 changes and then start deleting the older ones as new ones are done). This would benefit people with outdated computers a lot, I would put “unlimited” in the default config file though.

0 Likes

#2

I do not think the unlimited undo history is a problem as it should take a memory amount really small. So even if you stay typing on your Sublime Text for months. The point jps was taking is that if eventually for some millenniums, someone stayed typing on their Sublime Text, they would run out of memory as Sublime Text has an unlimited stack size for the undo history. I really like the infinity undo stack size. I do not like applications which limit the undo. However it is understandable for some applications which the undo history uses heavy amounts of memory.

Thought, if somehow you use too much memory due the undo history, you could close and one the view again (Ctrl+W, Ctrl+Shift+T) and the history should be cleaned. But there is a feature request on the core to allow the undo history to be persistent between Sublime Text sessions:

  1. https://github.com/SublimeTextIssues/Core/issues/108 Improve Undo/Redo

The problem pointed there cause by the pacakge GotoLastEditEnhanced, are the heavily add_region calls on the Sublime Text api by the package, which is using a huge amount of memory somehow (perhaps the selection objects are too heavy?). The solution to this for now, is not to use plugins/packages which heavily call the add_regions as the GotoLastEditEnhanced package is doing.

0 Likes

#3

As @addons_zz points out, there is no limit because there is no need for a limit even on very memory starved systems. Unless you write a package with some serious hacks, you’ll never run into the limit.

This would benefit people with outdated computers a lot

If you do run into memory limits, how would you know what number to put into the undo history limit preference? Do you give it some random value on the off chance it may one day save you from running into crash?

Are people with outdated computer actually running into performance issues with a text editor as efficient as Sublime? If you can’t make a whole bunch of edits in Sublime you probably also can’t visit a website in Google Chrome. Or does “outdated” here mean “from the nineties”?

0 Likes

#4

Yeah you’re right I definitely overestimated how much memory it consumes, sorry.

0 Likes

#5

No problem.

I think the best approach would be set how much memory each view can consume. So when that amount is reached, Sublime Text starts discarding undos until that limit to be satisfied. However it could cause the problem where all undo histories are discarded when a recent change introduces change bigger than the undo limit the view has as acceptable.

1 Like