Browse Source

[metadata] Prevent text case mismatch before the cursor for predictions

Johan Ahlen 4 years ago
parent
commit
a34bf0af41

+ 4 - 3
desktop/core/src/desktop/js/apps/editor/components/aceEditor/acePredict.ts

@@ -72,9 +72,10 @@ export const attachPredictTypeahead = (editor: Ace.Editor, connector: Connector)
             beforeCursor: editor.getTextBeforeCursor(),
             afterCursor: editor.getTextAfterCursor()
           })
-          .then(response => {
-            if (response.prediction) {
-              setActivePredict(response.prediction);
+          .then(({ prediction }) => {
+            const beforeCursor = editor.getTextBeforeCursor();
+            if (prediction && prediction.toLowerCase().startsWith(beforeCursor.toLowerCase())) {
+              setActivePredict(beforeCursor + prediction.slice(beforeCursor.length));
             } else {
               removeActivePredict();
             }