File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
lib/src/widget/completion Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -109,10 +109,15 @@ class Suggestion {
109109 final suggestions = completion.options.map ((option) {
110110 final overlap = _lcs (prefix, option);
111111 var html = option;
112+ // highlight the overlapping part of the text
112113 if (overlap.isNotEmpty) {
113114 html = html.replaceAll (
114115 overlap, '<span class="completion-overlap">$overlap </span>' );
115116 }
117+ // include matched prefix as part of the display option
118+ if (completion.terminal) {
119+ html = '$match $html ' ;
120+ }
116121 final score = (option.startsWith (word) ? math.pow (overlap.length, 3 ) : 0 ) +
117122 math.pow (overlap.length, 2 ) +
118123 (option.startsWith (overlap) ? overlap.length : 0 ) +
Original file line number Diff line number Diff line change @@ -68,50 +68,50 @@ void main() {
6868 'start' : 0 ,
6969 'end' : 5 ,
7070 'value' : 'is:flutter-favorite ' ,
71- 'html' : 'flu<span class="completion-overlap">tt</span>er-favorite' ,
71+ 'html' : 'is: flu<span class="completion-overlap">tt</span>er-favorite' ,
7272 'score' : 4.125 ,
7373 },
7474 {
7575 'start' : 0 ,
7676 'end' : 5 ,
7777 'value' : 'is:unlisted ' ,
78- 'html' : 'unlis<span class="completion-overlap">t</span>ed' ,
78+ 'html' : 'is: unlis<span class="completion-overlap">t</span>ed' ,
7979 'score' : 1.125 ,
8080 },
8181 {
8282 'start' : 0 ,
8383 'end' : 5 ,
8484 'value' : 'is:dart3-compatible ' ,
8585 'html' :
86- 'dar<span class="completion-overlap">t</span>3-compa<span class="completion-overlap">t</span>ible' ,
86+ 'is: dar<span class="completion-overlap">t</span>3-compa<span class="completion-overlap">t</span>ible' ,
8787 'score' : 1.0625 ,
8888 },
8989 {
9090 'start' : 0 ,
9191 'end' : 5 ,
9292 'value' : 'is:legacy ' ,
93- 'html' : 'legacy' ,
93+ 'html' : 'is: legacy' ,
9494 'score' : 0.0 ,
9595 },
9696 {
9797 'start' : 0 ,
9898 'end' : 5 ,
9999 'value' : 'is:null-safe ' ,
100- 'html' : 'null-safe' ,
100+ 'html' : 'is: null-safe' ,
101101 'score' : 0.0 ,
102102 },
103103 {
104104 'start' : 0 ,
105105 'end' : 5 ,
106106 'value' : 'is:plugin ' ,
107- 'html' : 'plugin' ,
107+ 'html' : 'is: plugin' ,
108108 'score' : 0.0
109109 },
110110 {
111111 'start' : 0 ,
112112 'end' : 5 ,
113113 'value' : 'is:wasm-ready ' ,
114- 'html' : 'wasm-ready' ,
114+ 'html' : 'is: wasm-ready' ,
115115 'score' : 0.0 ,
116116 },
117117 ]);
You can’t perform that action at this time.
0 commit comments