Code editor feature requests


#1

In my day job I write code in Visual Studio, typically C# for Unity games (screenshots are from an old personal C++ project though). Outside of my day job, time/energy permitting, I write Lua code for my Defold game in the built in code editor. There are a few features from VS/Unity that I sorely miss as they dramatically cut down on wasted time and mental energy. These are in no particular order because I use every one of these features dozens of times every day and get frustrated every time I can’t use them in Defold. Some of these are at least partially available when debugging in Defold but would be just as useful when editing.

  1. Function list. At the top of any file is a dropdown list of every function in that file, clicking one takes you to it. This dramatically reduces the amount of reading and scrolling needed to navigate large files and reduces wasted time spent moving around in the code trying to find that thing you were looking for to help with that other thing you’ve already forgotten because it took so much time and mental effort just to get where you needed to be. VS lists them alphabetically, sometimes I wish they were in order of definition, or visibility (e.g. all global/public functions first then all local functions).

  2. Detailed scrollbar overlays . VS provides a lot of super useful information on it’s scrollbars, I’m sure there are others but in these screenshots alone I can see areas of the code I’ve edited since VS has been open (green is saved changes, yellow is unsaved); where breakpoints are (dark red); where errors are (bright red); where the cursor is (white line); which section of code is on screen (darkened box). Highlighting the sections of code I’ve edited is critical; almost every feature or fix involves jumping around between a handful of functions across several large files and the scrollbar overlays make navigating between just those arbitrary sections effortless. I miss this more and more as my Defold project grows, it may be my top request.
    Partial ‘map’ scrollbar:
    image
    Partial regular scrollbar:
    image

  3. Configuration. A code editor should not dictate how I format my code. Almost every line of code I write in Defold I am fighting against the autocomplete and autoformatting, please let me customize it or at least just let me turn it off. I’d be faster and way less frustrated without it. It makes me not want to write code out of pure frustration. I already had some parentheses, I didn’t want those argument names, I specifically indented it that way for a reason, just get out of my way.

  4. Member autocomplete (‘intellisense’) for tables. I know Lua isn’t a compiled language but this is still completely possible and would make working in large projects with various complex tables much easier. Being able to see what data members a table has would reduce the amount of things you need to hold in your head.
    image

  5. A better log console. Unity’s console window is also not up to scratch, in every project I include the free or paid version of the asset store plugin Console Enhanced. It has categories (info/warning/error/custom) that can be toggled on or off, it has a search filter (Defold’s console is searchable but still shows entries that don’t match the search), it has options to include the time and/or frame of each entry. Most important of all it has a clickable call stack for every log. Want to know where this function was called from or who called it first? Good luck! It just feels silly when Defold tells me I got a nullref on line X of file Y and I can’t click that message to go there. Also nobody ever tells you which of the potentially many objects in the line triggered the null, which is stupid.

  6. Let me print whatever the hell I want. I don’t care if it’s a bool or nil or a table or what, just concatenate the strings and log the damn thing.

  7. Peeking. This is another feature that dramatically reduces navigation time and energy. I want to call a function, or I’m looking at an existing function call, and I want to know what that function does but I don’t want to navigate there because I’m in the middle of something. Right-click -> Peek definition. I’m using a constant defined at the top of the file and I want to quickly add another one. Right-click -> Peek definition. I peeked a function and it calls something I wasn’t aware of, now I want to peek that function. Right-click -> Peek definition, now my peek window has a stack I can navigate along. All. The. Time. Also right-click -> Go to definition for when I actually do want to go there.


#2

I still think what the Defold team should do is quit the built-in editor and develop a kickass VSCode extension, or even their own spinoff of it like Kode for Kha. Game Maker is stuck in the same limbo, I just don’t see the justification for developing your own editor now a days. There are great, free OpenSource options out there.

There is an Atom extension though, it’s made by a community member.


#3

Thank you so much for the great feedback @connor.halford! Much appreciated! @mats.gisselson and @Erik_Angelin know which of these suggestions we already have in our backlog.


#4

The code editor is a tiny fraction of what the Defold editor is as a whole. The bulk of the time spent improving our editor goes towards other areas, so throwing out the editor wouldn’t free up much time. I still believe that having a built in code editor is a real advantage. We want Defold to be a turn key solution. You should be able to download Defold and be productive straight away and not have to download additional software, build tools or extensions.


#5

I agree that having a built in code editor is advantageous, not least because it’s lightweight. I have a tiny SSD for my C drive and programs like VS demand an outrageous amount of it, plus they may not even run on netbooks and other lightweight laptops designed for portability not power. That said, Defold does still rely on external software for audiovisual assets so it’s not that big of a jump to rely on external software for code as well.


#6

Using an external editor is not something we want to rely on. And if we were to rely on an external editor we’d still not satisfy everyone since everyone has their favorite editor. And you can still use your favorite one if you want to, and as was pointed out there’s community created integrations for Atom and others.


#7

Well, yes, you need Spine or Dragonbones to edit spine models and music/sfx tools to create sound effects and music, and Blender/Maya/3DStudio Max to create models, and Photoshop to create 2D graphics. All those tools are huge and it would be silly if we tried to recreate them. Some might argue that it’s silly to focus on a code editor, but I think it’s such an essential part of an editor for an engine such as Defold that it would make sense to include at least a decent editor. If only for ease of integration with the debugger and how it allows anyone to open Defold, launch a tutorial and get going.


#8

laughs in MS Paint


#9

Well, Photoshop is overkill really, I don’t use it myself, bu I was typing on a phone and it was slow going as it was without listing all the excellent tools for pixel art etc


#10

These are all great suggestions that we eventually want to implement. We’re not done with the built-in code editor, but our resources are a bit stretched at the moment so it might be a while until we can implement all of them.

I’ve made sure these have issues on the editor2-issues tracker.

1. Function list

2. Detailed scrollbar overlays

3. Configuration

I added this for your specific concerns:

There are already few reports about the auto-indentation behaving badly:

Choosing a default indentation style for new files:

Customizing the color scheme:

4. Member autocomplete (‘intellisense’) for tables

We already have multiple issues about proper autocomplete support:

And autocomplete definitions for native extensions:

5. A better log console

Clickable call stack:

Support for coloring console output:

I added a feature request for timestamps:

I added these two for filtering messages by type or text:

6. Let me print whatever the hell I want

This is an issue with Lua. The concatenation operator .. will not be able to concatenate a table onto a string unless the table specifies a __concat implementation in its metatable. We probably don’t want to change how Lua works in Defold, but instead of concatenating you can use a custom logging function that simply takes a bunch of arguments and outputs them to the console in whatever way you want. There are probably some good choices for logging modules written by the community. You can also use the built-in pprint function to format output of multiple items by putting them in a table like this:

pprint {
    message = "Something happened",
    data = {x = 4.0, y = 3.0}
}

7. Peeking

I added this:


#11

Thanks for such a detailed response! I didn’t realise you could use pprint that way, will look into it thanks


#12

Hm, I was also surprised. Would be good to update manual that you can use pprint {'something', 'some_object' = some_object}, really nice feature!

And thank you that you caring about editor - it’s really important to have modern features integrated to our editor and not use VSC or IntelliJ instead.


#13

Hmm, I now realize I my pprint example above might be slightly misleading. It will pretty-print the table you give it as an argument literally. There is no special handling of the message and data keys or anything like that. So the above will output the following to the console:

DEBUG:SCRIPT: 
{
  message = Something happened,
  data = {
    y = 3,
    x = 4,
  }
}

My point was that you could quite easily write a custom log function that takes a variable number of arguments (or a table) and have it concatenate the output in any way you wish. The pprint function is just an example of that.

Sorry I was unclear!


#14

Even though I’m not really a fan of overriding/replacing built in functions I think it can sometimes be acceptable to replace the print() function to pretty print tables. An example:


#15

Sometimes I forget that Lua is just wild and will let you do whatever the hell you want, including redefining library functions :slight_smile:


#16

Just want to bump this. Particularly would like the ability to turn off the auto formatting part of the editor - I’m constantly fighting it at the moment. I’d rather use the built-in editor rather than having to continually switch back and forth to an external editor. The auto complete is generally okay though.