Skip to content

Commit a34bf0a

Browse files
JohanAhlenromainr
authored andcommitted
[metadata] Prevent text case mismatch before the cursor for predictions
1 parent e6ad166 commit a34bf0a

File tree

1 file changed

+4
-3
lines changed
  • desktop/core/src/desktop/js/apps/editor/components/aceEditor

1 file changed

+4
-3
lines changed

desktop/core/src/desktop/js/apps/editor/components/aceEditor/acePredict.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ export const attachPredictTypeahead = (editor: Ace.Editor, connector: Connector)
7272
beforeCursor: editor.getTextBeforeCursor(),
7373
afterCursor: editor.getTextAfterCursor()
7474
})
75-
.then(response => {
76-
if (response.prediction) {
77-
setActivePredict(response.prediction);
75+
.then(({ prediction }) => {
76+
const beforeCursor = editor.getTextBeforeCursor();
77+
if (prediction && prediction.toLowerCase().startsWith(beforeCursor.toLowerCase())) {
78+
setActivePredict(beforeCursor + prediction.slice(beforeCursor.length));
7879
} else {
7980
removeActivePredict();
8081
}

0 commit comments

Comments
 (0)