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

Hans-Jörg Bibiko bibiko at eva.mpg.de
Tue Sep 18 10:44:36 UTC 2012


On Sep 18, 2012, at 12:00 PM, Allan Odgaard wrote:

> 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.

Hmm, unfortunately an "afterDelay:0.0f" doesn't work all the time. I did some tests with a delay of 0.1f and it seems to work. That's why I re-wrote the code to do a performSelector: only if TM2 opened a new doc, otherwise it passes it directly to the text view.

Cheers,
--Hans


PS What do you thing about using DIALOG as API for stuff like "$DIALOG setCursorTo --line 10 --column 20" , "$DIALOG selectText --from 10 --length 20" etc. ? 




More information about the textmate-dev mailing list