complete icon indicating copy to clipboard operation
complete copied to clipboard

Set custom prefix filter on predictor

Open WillAbides opened this issue 6 years ago • 4 comments

This replaces #99. I didn't like that you had to change the filter for all arguments or nothing there. This allows the custom prefix filter to be set in the predictor.

It adds the PrefixFilter interface. When a predictor implements PrefixFilter, it will use the supplied filter instead of the default strings.HasPrefix. A new type PrefixFilteringPredictor is also introduced. It wraps both a Predictor and a PrefixFilter.

WillAbides avatar Jul 06 '19 22:07 WillAbides

Codecov Report

Merging #100 into master will increase coverage by 0.23%. The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master   #100      +/-   ##
========================================
+ Coverage   89.76%    90%   +0.23%     
========================================
  Files          12     13       +1     
  Lines         879    900      +21     
========================================
+ Hits          789    810      +21     
  Misses         79     79              
  Partials       11     11
Impacted Files Coverage Δ
complete.go 67.64% <100%> (-4.15%) :arrow_down:
prefixfilter.go 100% <100%> (ø)
command.go 100% <100%> (ø) :arrow_up:
predict.go 90.9% <100%> (+7.57%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 2f2ff27...0aa33eb. Read the comment docs.

codecov[bot] avatar Jul 06 '19 22:07 codecov[bot]

Thanks for the comments. I am away at a company event this week, so I can’t make any updates immediately. I should be able to address the comments within a week.

I just wanted to let you know so you don’t think this is an abandoned drive-by PR.

WillAbides avatar Jul 09 '19 19:07 WillAbides

@posener, Do you have a suggestion for a better name than PrefixFilter? It was the best name I could think of at the time without reusing any terms that are already in use in the project. I half expected your first bit of feedback to be "That name is awful, you should call it X".

WillAbides avatar Jul 11 '19 19:07 WillAbides

@posener, Do you have a suggestion for a better name than PrefixFilter? It was the best name I could think of at the time without reusing any terms that are already in use in the project. I half expected your first bit of feedback to be "That name is awful, you should call it X".

:-)

I would go with Matcher, as it allows you to do different sorts of matching between the completed word and the completion option.

posener avatar Jul 14 '19 18:07 posener