CompletionPrefix sections from .xctxtmacro files are ignored in Xcode 3.2

Originator:andre.bergmedia
Number:rdar://7219873 Date Originated:13-Sep-2009
Status:Open Resolved:No
Product:Developer Tools Product Version:3.2 / 1610
Classification:UI/Usability Reproducible:Yes
 
13-Sep-2009 11:17 PM Andre Berg:
Summary: 

In Xcode 3.1 and below I was able to add CompletionPrefix sections to my xctxtmacro files so that I could type these strings in my source code and have them replaced by the template the CompletionPrefix section belongs to. This seems to be completely ignored in Xcode 3.2

Steps to Reproduce:

1. Make sure xctxtmacro files are valid
2. Have at least the default CompletionPrefix section by Apple or your own 
3. Restart Xcode
4. Check Xcode menu "Edit > Insert Text Macro > YOUR_CATEGORY" to see that indeed you have a valid xctxtmacro file and all your defined templates are to be found in this submenu.  
5. Type a completion prefix in your source code (e.g. 'nsma' for ‘NSMutableArray‘, or 'if' for 'If / Else Block')

Expected Results:

The inline source code assist dropdown should come up with the exact name of the template from xctxtmacro file matching the completion prefix sequence you just typed.

Actual Results:

Inline sourc code assist dropdown comes up but only suggestions from documentation and source code index are shown while no templates from xctxtmacro file.

Regression:

Xcode 3.1 on Leopard 10.5.8 does not show this behaviour. 

Notes:

A workaround for now until this is sorted out would be of course to just insert the txtmacros from going to the top Xcode menu, but boy this is driving me crazy and is more disruptive to my workflow than just typing it all out.

13-Sep-2009 11:41 PM Andre Berg:
'ObjectiveC.xctxtmacro' was successfully uploaded

23-Sep-2009 05:00 PM Andre Berg:
Another workaround I have found is if you put the insertion caret behind a statement terminated by a semicolon and then type the completion prefix it will get reckognized. If you type two consecutive semicolons on a line on their own and then put the insertion point behind the second semicolon your completion prefixes will also get correctly interpreted. For now I am using those two techniques to avoid going all the way up to the menu searching for the entry and inserting it. It's not as fluent as hitting two, three letters and tab but it will do for now.

03-Oct-2009 02:31 AM Andre Berg:
And so it turns out that you need to set a new value in your xctxtmacro files in order for your own specifications to show up:
 
If you add "OnlyAtBOL = YES;" to each macro unit which doesn't appear to show up it will then work.
At least that's how I got it to work again.
 
I am guessing that BOL stands for "Beginning of Line" which would also explain why my macros would work when the insertion caret was directly after the closing semicolon of the previous line.
 
So actually the effect if you set it to YES seems to be that you can then use your macro anywhere except at the end of a line.
 
A bit weird but whatever works, works. 

PS: I am leaving the bug unresolved for now as I don't know if what I describe is the intended behaviour.

Comments

See more details in rdar:///7221040 This is due to a bug with the "OnlyAtBOL" new key introduced in xctxtmacros.

Defining OnlyAtBOL=YES for your textmacro will make the macro work with autocompletion (but only when you're at the beginning of a line obviously). But macros with OnlyAtBOL=NO or undefined won't work with autocompletion whereas they should.

By olivier.halligon at 2009-09-17 08:36:50.672037 (reply...)

Thanks!

Hi Olivier,

Thanks for taking the time to reply to my radar. Looks like you got to the bottom of this sooner than me :)

By andre.bergmedia at 2009-10-09 03:33:23.145742 (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!