ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

dynamically indent comments in decompiler view

Open williballenthin opened this issue 6 years ago • 4 comments

Is your feature request related to a problem? Please describe. The decompiler view emits comments at a static indent level. When code is nested at various levels, such as with if or while blocks, then indentation changes, and comments don't line up with other source code.

Describe the solution you'd like For the indentation of comments to match that of the surrounding source code.

Additional context

static comment indentation configuration:

image

example showing comments not lining up with surrounding source code:

image

williballenthin avatar May 06 '19 17:05 williballenthin

This is a very good request, I second that. If you have spaghetti functions with lot of indentation to analyze the comments sometimes make the code even less readable if they stay at the fixed indention level. A dynamic placement would greatly improve the readability.

alexander-pick avatar Aug 18 '19 06:08 alexander-pick

I've created #3472 to implement this. The screenshot below shows how it appears in the decompiler view and tool options:

image

It's set to a default of 'off' in order to match current functionality, though personally I think it makes more sense to start with it on by default. I'm happy to switch it to be on by default.

Of course I can make whatever other updates are needed, but want to get feedback before I go too far down into something. I've also included tests for existing functionality as well as the new feature's functionality.

goatshriek avatar Oct 04 '21 00:10 goatshriek

Any updates on this? I would love to see this feature in Ghidra :)

voltangle avatar Jun 02 '25 18:06 voltangle

I haven't tested my changes in quite a while, and it looks like there are now conflicts that need to be resolved. I'm hesitant to put any more time into this though, particularly since this isn't my only PR to this repo that is stuck in purgatory.

goatshriek avatar Jun 02 '25 19:06 goatshriek