[txmt-dev] Re: DIALOG x-insert - bug - a fix suggestion

Allan Odgaard mailinglist at textmate.org
Tue Sep 18 10:00:14 UTC 2012


On Sep 18, 2012, at 11:19 AM, Hans-Jörg Bibiko <bibiko at eva.mpg.de> wrote:

> I know this is not the preferred way to send a change request but it's only one entire file:

Hopefully final version will be a real pull request :)

> The idea is to find the front most OakTextView first and then to process insert_text or insert_snippet. 
> If no OakTextView was found it creates a new untitled document before inserting. Here I have a problem: How to know after invoking newDocumentAndActivate: whether TM2 did load the new window entirely? I solved it tentatively by using usleep(10000) to give TM2 a bit time but this is _not_ elegant. The issue here is that it happened to me in 10% of all trials that "insert_text" was faster then the initialization of the new doc, i.e. I saw the inserted text for a few msecs before the initialization routine replaced its content by @"".

Try use performSelector:afterDelay: (with 0) — the problem is often that work is delayed until the end of the current iteration of the event loop. By using performSelector:afterDelay: you get your code executed on the next iteration of the event loop.



More information about the textmate-dev mailing list