godot icon indicating copy to clipboard operation
godot copied to clipboard

GDScript: Highlight script members like native ones

Open dalexeev opened this issue 1 year ago • 6 comments

Closes godotengine/godot-proposals#6428.

dalexeev avatar Mar 04 '23 21:03 dalexeev

Damn that was so fast, I didn't think anyone would give my proposal a second thought. I appreciate it a lot, it'll help me (and hopefully others) a lot.

yatesm4 avatar Mar 04 '23 21:03 yatesm4

LGTM, I was thinking roughly the same implementation while looking into why this happens. update_cache() is starting to get quite heavy, but it's probably not a problem.

MewPurPur avatar Mar 04 '23 22:03 MewPurPur

How does it look when you shadow member variables in functions and code blocks?

and-rad avatar Mar 09 '23 11:03 and-rad

Right now the highlighter doesn't use code analysis, so if you have identifier shadowing, highlight collisions are possible.

dalexeev avatar Mar 09 '23 11:03 dalexeev

I think that's something it should be able to do, otherwise it would add potential for confusion that's not present right now.

and-rad avatar Mar 09 '23 13:03 and-rad

The confusion is already there, if you shadow a native property or use inner classes with name collisions. To fix this, we need to rewrite the highlighter. I have some ideas how to do this without using the parser and analyzer, but for now I would prefer this solution with minimal changes, even if it is not perfect.

dalexeev avatar Mar 09 '23 14:03 dalexeev

You're right, but look at it this way: Right now members aren't highlighted, which is a pity but at least the editor doesn't lie to you. If members were highlighted, but sometimes not correctly, there'd be a bug now where previously there was none. That doesn't sound right to me.

and-rad avatar Mar 09 '23 20:03 and-rad

No, the editor could lie to you before, in the case of native members. You are not suggesting to stop highlighting them to avoid the error, right? Most of the highlighters that I have seen in various text editors and other interfaces were not perfect, to one degree or another.

Also, shadowing identifiers is not recommended - it causes a warning by default. I still see this change as doing more good than harm. But yes, we should think about a significant overhaul of the highlighter in the future.

dalexeev avatar Mar 09 '23 21:03 dalexeev

poke poke?

MewPurPur avatar Aug 26 '23 20:08 MewPurPur

Bless you. What's the status of this? May I poke in, too? It's a huge QoL improvement.

Mickeon avatar Oct 20 '23 10:10 Mickeon

Any news? I need this in my life.

Bless you. What's the status of this? May I poke in, too? It's a huge QoL improvement.

TinyTakinTeller avatar Jan 01 '24 16:01 TinyTakinTeller

@TinyTakinTeller Please don't bump without contributing significant new information. Use the :+1: reaction button on the first post instead.

AThousandShips avatar Jan 01 '24 16:01 AThousandShips