Three years ago I was doing a presentation about something or other about NAV at a non-NAV conference. That’s in front of normal developers. And you can imagine what their impression was of the state of the technology when, in front of a couple of hundred mostly C# developer, I opened the C/AL editor.
I don’t need to be concerned about that anymore, because Microsoft Dynamics NAV 2016 comes with a new code editor, which comes with a number of features the whole NAV community way hoping for since I remember. And I started forgetting a long time ago.
Namely, we now have:
- Proper syntax highlighting
- Line numbers
- Change indicators
- Auto-complete intellisense style. Ish.
- Syntax tooltips
- And – hold your seats! – undo!
Let’s take a look at each of those.
Here, the first three points are obvious. Syntax highlighting properly shows keywords, operators, strings, comments… even block comments are properly interpreted, so the caveat “do not use block comments because they do not show properly in the syntax” loses ground. You should still not use block comments, but at least not because of syntax highlighting (cough, poweshell compare, cough).
The second obvious thing is that we now see line numbers. Not that it helps too much by itself, but the code is now easier to refer to.
Then, change indicators are absolutely lovely. While you are editing, the lines you edited are marked with yellow, and as long as you didn’t save the object, they will stay yellow. When you save, the line indicators will turn green:
At this point, I’ll file my first complaint. When you close the editor, without closing the object (e.g. in the table or page designer, you go back from code editor to layout or field designers) and then return to the code editor, the change indicators are gone. Too bad, but still this is a welcome feature.
Autocomplete is a great replacement for the Symbol Menu (which is still there) and it allows you to quickly select among the possible operators, keywords, variables, constants, functions, members, etc.
For example, on a record I see available fields:
You can quickly tell the type of symbol, such as fields from functions, by observing the icon. Okay, in all honesty, I don’t know what the key icon means as opposed to that green boxy thing. They are not keys, they are not flow fields, so what exactly are they? If you know for a fact – please share.
The autocomplete feature is invoked by pressing Ctrl+Space just like in Visual Studio, and it filters as you type. Pressing key up or down allows you to select a symbol, and pressing Enter completes the entry. Sweet.
There are a couple of problems, though. First, the good old Symbol Menu allows you to see all the symbols, but won’t allow you to complete code. Pressing Enter or doubleclicking a symbol there won’t put it into your code. That’s a pity. And probably a bug.
The other problem is about .NET. Any .NET variables are autocompletable on the first level only. After you enter . after a .NET object, you’ll see the list of its members, but if a member is .NET type, entering another . will not show the member’s members:
Syntax tooltips are great, and they show you how to call a function or invoke a method:
The tooltip pops up the moment you open a parenthesis and shows you the arguments of the function you are calling. Unfortunately, it doesn’t work with overloaded methods, so it’s another thing to put on my wish list.
And finally, last, and definitely not the least, is undo. Whatever changes you make to code, you can undo them. I don’t know if there is a number of changes that are undoable, but from all I can tell – there isn’t one. Undo only works until you close the code editor, which is okay for codeunits. However, if you are editing a table, or a page, make sure you don’t close the code editor when switching from code and table/page/report/… designer. If you close the editor, the undo history is gone. Still, I won’t whine about this. We lived without any undo forever, so this little change is the most welcome change and one that will – I am sure – save thousands of hours for developers worldwide.
It was a long wait, but having it in 2016 is better than having it never. Good job, Microsoft!