This post is part of a series in which I want to take a closer look at some of the features and functionality in Fire, our new IDE for the Mac. The topic for today is Code Completion.

Code completion, also called IntelliSense in Visual Studio parlance, is a crucial part of writing code these days. Instead of reading docs or knowing types and their members by heart, we rely on Code Completion to let us know and discover what APIs are there for us to use. And gone are the days of trying to save keystrokes by making names easy to type — because CC can help us type complex names, easily.

Of course Fire comes with state-of-the-art Code Completion in its code editor, driven by the same back-end engine that also provides CC data for our languages in Visual Studio. But while the content is the same, Fire takes the CC user interface to the next level, as we have really put a lot of thought into how we can improve the general experience.

In Fire, Code Completion will automatically activate as you type, wherever sensible. So you don’t need to think about it much, and it will automatically be there to help you, should you need it. Of course you can also manually invoke CC at the current cursor location, if so desired. You can either press Escape (which is the Mac default for this), or — if you’re still used to Visual Studio, and maybe switching a lot between the two IDEs — you can use Cmd-Space (after changing the global Spotlight shortcut, which you probably already did to use that combo on your VM, anyways).

CC is fast, but sometimes even the tiniest of interruptions can be annoying, so CC in Fire is completely asynchronous. Even while CC gathers info to show you, you can keep typing, or cursor elsewhere. If you type more of the current identifier, CC will adjust as you type to narrow your search. If you type or move away from the current identifier, CC will close (or never show, if you’re a really fast typer ;).

The CC “Soft Selection”

As Code Completion gets activated, you will notice that Fire will add a soft highlight to the current “token” that it considers relevant. This is a helpful indicator as to what part of your code will be replaced should you accept an item from the CC list.

![](http://f.cl.ly/items/3j3G1O2R2t221N1G0217/Image%202014-09-08%20at%2012.52.58%20PM.png)
If you use Visual Studio, you might have (consciously or subconsciously) noticed that sometimes when you select an item from CC, VS will replace the *full* token you are on, and other times, it inserts the new text *in front* of the existing text. If you’re like me, on more than one occasion you’ll have been annoyed that it did the opposite of what you wanted or expected. Fire’s visual indicator helps with that. For example, if you start typing at the very front of a token, chances are that you are adding a new token in front and don’t want to replace what’s already there, so CC will not absorb the text behind the cursor:
![](http://f.cl.ly/items/2L2L463j1O3h2L1o2M1t/Image%202014-09-08%20at%2012.22.18%20PM.png)
But if you invoke CC in the middle of an identifier, chances are you want to replace the whole identifier, so Fire’s UI will reflect that:
![](http://f.cl.ly/items/2l1w000a3z0H3b19063m/Image%202014-09-08%20at%2012.32.35%20PM.png)
Not only does the “soft selection” show you what to expect, but Fire is also smart about picking the right “mode” for CC, depending on the context it finds itself in.

Partial CC

Fire’s CC also has a nifty way that helps you type complex names. Take the following example of very common Cocoa code:

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_NORMAL, …)

That is a huge pain to type, even with CC, because each the three identifiers starts with “dispatch_”, and there’s a huge list of those. So you end up either typing most of the names manually or doing a lot of scrolling through the CC list. Not anymore!

In Fire, when you press Tab or underscore (_), CC will automatically advance to the next underscore in the current item (or to the next item with an underscore. So for example, if you just type dis_g_g_q(, CC will smartly navigate you through the list so that you end up with dispatch_get_global_queue(|):

![](http://f.cl.ly/items/1P3d1F1f131D1z0x3S0P/Screen%20Recording%202014-08-29%20at%2007.08%20PM.gif)
Similarly, Tab also jumps ahead between parts of PascalCased names. So it’s just `NSFilMa` and you have `NSFileManager`.

The Devil’s in the Details

There are other small details that streamline the CC experience. When CC gets invoked and there’s no current token to soft-select yet (the most common case when you’re starting a new identifier), Fire will show a small “sliver” of a soft selection to the right of the cursor to show you CC is coming:

![](http://f.cl.ly/items/3w221z2w3K0K1U2X3l1K/Image%202014-09-08%20at%2012.37.31%20PM.png)
If you accept CC for a method by typing `(`, Fire will automatically insert the pair of parenthesis and put the cursor between them — if you accept CC with a different key, for example with space or enter, it will not.

Of course CC also handles multi-part method names in Oxygene, C# and Silver (even if they look like named parameters in the latter) — inserting the full method signature for you, and giving you “jump points” to let you tab from one parameter to the next:

![](http://f.cl.ly/items/1b182M3u3c2u0M1i3D1I/Image%202014-09-08%20at%2012.56.50%20PM.png)
If you ignore CC and “type through”, CC will smartly do the right thing when you come to the end of the identifier. For example, it will adjust the case of what you typed to the proper item in CC. But not if the version you typed would *also* be valid, as in the case below (which of course only happens in case sensitive languages, i.e. C# and Silver):
![](http://f.cl.ly/items/0r3f3z2c131z423u3a1r/Image%202014-09-08%20at%2012.45.45%20PM.png)
When you start typing in the middle of an existing identifier, CC will not drop down automatically. Chances are you’re trying to fix a typo or otherwise know what you’re doing, and our use testing showed that the CC dropdown just gets in the way. (Of course you can still invoke CC manually via Escape for that location — it will then cover the entire identifier.)

Just like these, there are lots of little tweaks and and “special cases” — some even language-specific — that fine-tune CC to behave as you’d want it to and not get in the way. Most of them being cases that you won’t actually notice — except by lack of being annoyed ;).

Summary

This post gave you a quick look at what Code Completion is like in Fire. Code Completion is implemented as part of Fire’s Code Editor, which we have written from scratch to give you the best possible code editing experience. I’ll talk more about the Code Editor in general in a future post.

Stay tuned, check out Fire, and make sure to let us know what you think!

—marc