orbitalquark / textadept

Textadept is a fast, minimalist, and remarkably extensible cross-platform text editor for programmers.
https://orbitalquark.github.io/textadept
MIT License
654 stars 39 forks source link

Buffer positions history in Textadept and Textredux #106

Closed rgieseke closed 3 years ago

rgieseke commented 3 years ago

The saving/restoring of buffer positions changed with the latest beta

https://github.com/orbitalquark/textadept/blob/1e693f06a6556b87ed4f56a3635a0c10640b1f92/modules/textadept/history.lua

This interferes with Textredux' handling of search text where the position at a filtered line should be kept.

I can workaround this as described in https://github.com/rgieseke/textredux/issues/76

events.connect(events.MODIFIED, function()
  if buffer._textredux then return false end
end, 1)

I wonder whether there could be a way to add some check to the checks to "ignore" in

https://github.com/orbitalquark/textadept/blob/1e693f06a6556b87ed4f56a3635a0c10640b1f92/modules/textadept/history.lua#L47

to detect something like Textredux use-case? (Maybe it's to special and i can use the above workaround.)

orbitalquark commented 3 years ago

Try the attached/following patch. It blocks the default attempt to restore the previous caret position when buffer contents are replaced. When the blocker is hit, it removes itself so that future, non-textredux events can still trigger the default behavior.

--- textredux-main/core/buffer.lua 2021-05-25 14:31:39.000000000 -0400 +++ textredux/core/buffer.lua 2021-06-11 11:29:59.005523457 -0400 @@ -288,6 +288,11 @@ self:set_save_point() end

+local function block_event()

rgieseke commented 3 years ago

Wicked! Thanks for the quick reply, this works very well.