orbitalquark / textadept

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

Default buffer properties not applied after a reset. #398

Closed jxzwp closed 1 year ago

jxzwp commented 1 year ago

In Textadept 12 try this. Open any file and then go to Tools > Quick Open > Quickly Open User Home, to open init.lua, which should be empty. Notice in the status bar it says "Spaces: 2" to indicate the tab width is 2. Now put buffer.tab_width = 3 in init.lua and save it. Perform a reset by typing reset in the command entry and pressing enter. In the status bar it says "Spaces: 3" Now switch to the other file you had open and the status bar will still show "Spaces: 2", but it should say 3 not 2.

The default buffer properties are not applied to all buffers after a reset, only the active buffer.

To fix this I added the following event handler at the very end of _HOME/init.lua

events.connect(events.RESET_AFTER, function()
  local orig_buffer = _G.buffer
  for _, b in ipairs(_BUFFERS) do
    _G.buffer = b
    load_buffer_settings()
  end
  _G.buffer = orig_buffer
end, 1)  -- the 1 is needed otherwise any RESET_AFTER handler in the user's init.lua will run before this

I tested this on a nightly from 7th May.

orbitalquark commented 1 year ago

Thanks, this should be fixed via https://github.com/orbitalquark/textadept/commit/b3b10d79307880c97733eac45c47a1b2a6f0765d and will be in the next nightly build.