orbitalquark / textadept

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

ui.print_silent_to() doesn't update the Tab label #529

Closed jxzwp closed 2 months ago

jxzwp commented 2 months ago

Put the following code in init.lua, save and restart Textadept, then press ctrl+1. A new buffer is created as expected, but the tab label is "Untitled" instead of "Test Buffer". When you switch to that tab the Textadept window title changes to "Test Buffer - Textadept (Test Buffer)", but the tab label remains "Untitled".

keys['ctrl+1'] = function() ui.print_silent_to('Test Buffer', 'hello') end

If you use the command entry to inspect the tab you get the following

print(buffer.filename) --> nil
print(buffer._type) --> 'Test Buffer'

As soon as you edit the content of the tab, the tab_label correctly updates to "Test Buffer" via the SAVE_POINT_LEFT event handler.

I think the issue is around here. Nothing is triggering a call to set_tab_label() for the new buffer. https://github.com/orbitalquark/textadept/blob/81180915559448f60101f1d3da61819b40591e83/core/ui.lua#L72

Note: ui.print_to() does not have this issue.

Thanks for all the work you've put into Textadept over the years.

orbitalquark commented 2 months ago

Thanks so much for the detailed report. This should be fixed in https://github.com/orbitalquark/textadept/commit/c0f1f39beaa392c6cd18379f831a7f8485dfe6a4