Jump to content

Snippet expansion with cursor placement in Xcode


Recommended Posts

I have a lot of snippets for programming-related tasks. An example is `[]` (open and closed square brackets) which expands into `"[{cursor}]". I have a similar snippet for two double-quotes, for regular parenthesis, etc. When I use these snippets in Xcode, and only in Xcode, any character before the parenthesis gets deleted. It seems this is because Xcode automatically deletes the opening parenthesis when the closing one is deleted (when Alfred expands the quote) so Alfred removes one "extra" character. See attached video.

 

What you were doing when the issue happened

Debugging ;)

 

Whether you were able to replicate it a second time by performing the same action

Yes, this always happens.

 

Include any screenshots that might help us

https://www.dropbox.com/s/8bz492m0oqy3eqy/bug-report-snippet-with-cursor.mov?dl=0

 

Include the Alfred version & build number you are using

v3.6 [901]

 

Include your OS X version

macOS High Sierra 10.13.3

Link to comment

@Hincin Unfortunately, there is no way for Alfred to know the underlying behaviour of Xcode... the snippet is 2 characters long, which is the equivalent of pressing backspace twice. When I do this manually in Xcode (as you've recognised), this deletes [] on the first backspace, then the character before it on the second, before inserting the snippet.

 

The only workaround is to use a keyword which doesn't get manipulated by Xcode, or if there is a way to turn off certain auto-replacements in Xcode, turn them off for your relevant matching snippet keywords.

 

Cheers,

Andrew

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...