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

Dirty markers on tabs don't update when using Save All #380

Closed jxzwp closed 1 year ago

jxzwp commented 1 year ago

In 12 alpha 2, when doing File > Save All, the * marker on tabs isn't removed for buffers other than the active buffer. All the dirty files are being saved, but the tabs aren't updating because SAVE_POINT_REACHED is only emitted for the active buffer, which triggers set_title() in core/ui.lua:272 to update just that tab.

My temporary fix is below. Modified set_title() in core/ui.lua:272

local function set_title(buf)    -- modified line
  local buffer = buf or buffer   -- new line
  local filename = buffer.filename or buffer._type or _L['Untitled']
  if buffer.filename then filename = select(2, pcall(string.iconv, filename, 'UTF-8', _CHARSET)) end
  local basename = buffer.filename and filename:match('[^/\\]+$') or filename
  ui.title = string.format('%s %s Textadept (%s)', basename, buffer.modify and '*' or '-', filename)
  buffer.tab_label = basename .. (buffer.modify and '*' or '')
end
ui.set_title = set_title         -- new line

Modified io.save_all_files() in core/file_io.lua:229

function io.save_all_files(untitled)
  for _, buffer in ipairs(_BUFFERS) do
    if buffer.modify and (buffer.filename or untitled and not buffer._type) then
      if not buffer.filename then view:goto_buffer(buffer) end
      if not buffer:save() then return end
      ui.set_title(buffer)  -- new line
    end
  end
  return true
end
orbitalquark commented 1 year ago

Thanks for the report. This should be fixed via https://github.com/orbitalquark/textadept/commit/1380fec2dd1c2ce9b5ced4b308c2a97ed933e8bd and be in the next nightly build.