Skip to content

Commit 5ad91c2

Browse files
authored
Merge pull request #6 from devforth/feature/AdminForth/1600/fix-these-errors-in-autocomple
fix: improve suggestion handling and ensure proper string checks
2 parents 26a26a6 + 69c8094 commit 5ad91c2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ export default class TextCompletePlugin extends AdminForthPlugin {
149149
content,
150150
maxTokens: this.options.expert?.maxTokens ?? 50,
151151
});
152-
let suggestion = respContent
152+
let suggestion = respContent || '';
153153

154-
if (suggestion.startsWith(currentVal)) {
154+
if (currentVal && typeof currentVal === 'string' && suggestion.startsWith(currentVal)) {
155155
suggestion = suggestion.slice(currentVal.length);
156156
}
157-
const wordsList = suggestion.split(' ').map((w, i) => {
158-
return (i === suggestion.split(' ').length - 1) ? w : w + ' ';
157+
const wordsList = suggestion.split(' ').map((w, i, arr) => {
158+
return (i === arr.length - 1) ? w : w + ' ';
159159
});
160160

161161
// remove quotes from start and end

0 commit comments

Comments
 (0)