Merge pull request #14318 from ToolJet/fix/codehinter-apply

Fixed incorrect anchor placement on selecting a suggestion
This commit is contained in:
Johnson Cherian 2025-11-27 17:56:28 +05:30 committed by GitHub
commit 6a9d40f4e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -162,13 +162,11 @@ export const generateHints = (hints, totalReferences = 1, input, searchText) =>
changes: pickedCompletionConfig,
};
const actualInput = removeNestedDoubleCurlyBraces(doc.toString());
if (actualInput.length === 0) {
dispatchConfig.selection = {
anchor: anchorSelection,
};
}
dispatchConfig.selection = {
anchor:
pickedCompletionConfig.from +
(completion.type === 'js_methods' ? completion.label.length - 1 : completion.label.length),
};
view.dispatch(dispatchConfig);
},
@ -331,11 +329,14 @@ export const getSuggestionsForMultiLine = (context, allHints, hints = {}, lang,
break;
}
}
dispacthConfig.selection = {
anchor: pickedCompletionConfig.from + completion.label.length - 1,
};
}
dispacthConfig.selection = {
anchor:
pickedCompletionConfig.from +
(completion.type === 'js_methods' ? completion.label.length - 1 : completion.label.length),
};
view.dispatch(dispacthConfig);
};
return hint;