godot icon indicating copy to clipboard operation
godot copied to clipboard

Consider search keywords in `CreateDialog`

Open RedMser opened this issue 1 year ago • 3 comments

Fixes https://github.com/godotengine/godot-proposals/issues/10573

Uses the search keywords defined on the class in order to improve search.

This works for any uses of the CreateDialog, such as adding a new node or creating a new resource file.

image

Similar to the docs search (F1), it only shows the suffix text if the name did not match the search text.

There is a weird bug when you search for whitespace, but this also was the case in 4.3 so unrelated to these changes.

RedMser avatar Aug 27 '24 14:08 RedMser

Aaah, I see how localization would be an issue. I thought your proposal would be using an entirely separate system, but reusing the existing keywords is somewhat more appropriate.

Mickeon avatar Aug 27 '24 17:08 Mickeon

Oh that's... that's such a rudimentary way to go about it. It's trying to create the class based off the whole string. So the actual class name should be store in the item's meta, instead.

Mickeon avatar Aug 31 '24 06:08 Mickeon

I can't believe I forgot to test the actual "instantiate" functionality, whoops. Fixed and rebased!

RedMser avatar Aug 31 '24 10:08 RedMser

  • Rebased onto latest master (fixed conflicts)
  • All concerns should be resolved now
  • Fully tested all functionality again (e.g. class_name, as well as the error case that Calinou ran into), works fine

RedMser avatar Jan 28 '25 22:01 RedMser

@Calinou I totally forgot to do this simple change, sorry for the wait! ^^'

Compared to docs search, I had to reduce the score multiplier to 0.1 for keywords, due to the different nature in which the score is computed here.

CreateDialog: searching for "omni":

score of  ConfirmationDialog  was  0.07775999605656
score of  OmniLight3D  was  0.27687272429466
score of  OpenXRCompositionLayerCylinder  was  0.0570240020752
score of  OpenXRCompositionLayerEquirect  was  0.0570240020752
score of  PointLight2D  was  1.0 (keyword "omni")

As you can see, using 0.9 multiplier wouldn't have reduced priority enough. It seems this is due to case-sensitivity + the fact that the keyword is very short + exact matches yielding max score.

RedMser avatar Feb 11 '25 20:02 RedMser

I believe this is safe to merge for 4.5...?

Mickeon avatar Apr 25 '25 20:04 Mickeon

Thanks!

Repiteo avatar Apr 28 '25 00:04 Repiteo