This fixes a regression. The previous commit window allowed a "--log" option to be specified that would pre-populate the text view with the given argument.
Presently the ‘TM_DISPLAYNAME’ is conditionally available, allowing the name to contain the file name which it will work with.
Also fix a potential “out of range” exception. The validateMenuItem: could be called for a cached menu item (e.g. when the system resolves key equivalents) where we had no selection (nor did click any item), so we would access the row at index -1.
Several crash reports indicate failure to create a CFString (in ct::line_t’s constructor). As we have an explicit UTF-8 check, I am not sure why it would fail, but at least now TextMate should not crash when it happens.
In practice we could source ‘.tm_properties’ with ‘TM_DISPLAYNAME’ set to “Commit” (and ‘TM_FILENAME/PATH’ unset) to use user’s ‘windowTitle’, though it could result in wrong titles for users who have configured window titles to include parent path components without proper fallback to ‘TM_DISPLAYNAME’.
For example the bundle item “Execute Line / Selection” will (without a selection) show as “Execute Line” in the menu, and now also if the command causes the error sheet to appear or the user press ⌃C / ⌘. to prematurely kill it.
This was previously necessary because we do threaded saving and relied on our run-loop source to be notified when saving completed, but as application termination (presumably) causes TextMate to run in a special run loop mode, we would not receive this notification.
After switching to dispatch queues there no longer is a problem (at least on OS X 10.9.2).
Closes#1030
This makes the abstraction redundant and it should be removed. I am doing that as a multi-step process, since the previous implementation was blocking tests from being updated to the new (dispatch queue based) test system.
When saving and the document needs to execute a command (e.g. callback.document.export) then we can no longer use our special run-loop mode, as command execution is now using queues, and queue dispatching is paused when running in a custom run-loop mode.
We still enable it when a custom completion command provides us with completion candidates. For example user might hit escape in a context where a file name should be inserted, without providing any initial prefix or suffix (as the number of expected candidates is small).
This resulted in missing proxy icon update e.g. when saving an untitled document over an existing one, as we would first set the path to the new location (and indirectly change the “is on disk” status without sending the proper notification).
If the format string itself does a replacement with potential captures $1-$n then we ensure that $1-$n are not inherited from the environment (which could be a parent regexp match).
This function is (indirectly) used by a lot of code, and not all of it provide with valid indexes, though it seems like an issue that can be fixed locally, hence why I have decided to allow it (coupled with this being the main reason for crashes).
It is however still not allowed when building in debug mode (rationale being that running it in debug mode and getting an assertion failure should provide enough info to fix the issue).
The rationale is that while the user is writing a commit message they might be reminded of something that should be fixed before committing, so they’ll cancel but wish to come back to the partially written message later.
Also skip checking for saved selection / visible index if there is no text in the buffer (since in this case, teh only valid values for seleciton / visible index are the default values).