Skip to content

Tolerance rate in Complishon#19456

Open
omarabedelkader wants to merge 5 commits intopharo-project:Pharo14from
omarabedelkader:tolerance-rate
Open

Tolerance rate in Complishon#19456
omarabedelkader wants to merge 5 commits intopharo-project:Pharo14from
omarabedelkader:tolerance-rate

Conversation

@omarabedelkader
Copy link
Copy Markdown
Contributor

@omarabedelkader omarabedelkader commented Mar 23, 2026

This PR adds typo-tolerant completion to the completion engine.
At the moment, completion depends on exact prefix matching. This means that a small typo can prevent the expected completion from appearing, even when the intended candidate is obvious. That makes completion less helpful in one of the situations where it should help the most: while the user is actively typing and makes a minor mistake.

To improve this, this PR introduces approximate matching based on the normalized Damerau-Levenshtein distance. When enabled, the completion engine can tolerate small typing errors and still propose close candidates. Exact prefix matches are preserved and still ranked first, while fuzzy matches are only considered as a fallback and are sorted by similarity.

For example, CoCompletionTolerance rate:0.4

  • if the intended varibale is Color and the user types a close but incorrect form such as Clor or Colr, completion can still suggest Color
Capture d’écran 2026-03-23 à 12 00 49

or

  • if the intended selector is printOn: and the user types a close but incorrect form such as prntOn:, completion can still suggest printOn:.
Capture d’écran 2026-03-23 à 12 01 08

P.S: The main trade-off is that increasing the tolerance too much can cause incorrect matches, so completion becomes noisy.

@omarabedelkader
Copy link
Copy Markdown
Contributor Author

By default the tolerance rate is 0.0 to be able to pass the tests

@omarabedelkader
Copy link
Copy Markdown
Contributor Author

Failed tests are unrealated

@Ducasse
Copy link
Copy Markdown
Member

Ducasse commented Mar 23, 2026

I'm wondering if we could not add a strategy and delegate to it. Like that we could avoid the duplication of the call chain.

@omarabedelkader omarabedelkader changed the title Tolerance rate Tolerance rate in Complishon Mar 24, 2026
@Ducasse Ducasse self-requested a review March 25, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants