From a33f6e01fbf14c34b0afd513a726bd122ad7b98c Mon Sep 17 00:00:00 2001 From: Mohamed Elshenawy Date: Sun, 22 Mar 2026 02:07:55 +0200 Subject: [PATCH] feat: add autocomplete keymap --- client/modules/IDE/components/Editor/index.jsx | 1 + client/utils/contextAwareHinter.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/modules/IDE/components/Editor/index.jsx b/client/modules/IDE/components/Editor/index.jsx index 474808da1c..426b5d11d7 100644 --- a/client/modules/IDE/components/Editor/index.jsx +++ b/client/modules/IDE/components/Editor/index.jsx @@ -197,6 +197,7 @@ class Editor extends React.Component { [`Shift-${metaKey}-Enter`]: () => null, [`${metaKey}-F`]: 'findPersistent', [`Shift-${metaKey}-F`]: this.tidyCode, + [`${metaKey}-Space`]: () => this.showHint(this._cm), [`${metaKey}-G`]: 'findPersistentNext', [`Shift-${metaKey}-G`]: 'findPersistentPrev', [replaceCommand]: 'replace', diff --git a/client/utils/contextAwareHinter.js b/client/utils/contextAwareHinter.js index a90b88cd0e..815a17182e 100644 --- a/client/utils/contextAwareHinter.js +++ b/client/utils/contextAwareHinter.js @@ -1,6 +1,7 @@ import getContext from './getContext'; import p5CodeAstAnalyzer from './p5CodeAstAnalyzer'; import classMap from './p5-instance-methods-and-creators.json'; +import * as hints from './p5-hinter'; const scopeMap = require('./p5-scope-function-access-map.json'); @@ -86,7 +87,17 @@ export default function contextAwareHinter(cm, options = {}) { const currentWord = string.trim(); const currentContext = getContext(cm); - const allHints = hinter.search(currentWord); + + let allHints; + + if (!currentWord) { + allHints = hints.p5Hinter; + allHints = allHints.map((h) => ({ + item: h + })); + } else { + allHints = hinter.search(currentWord); + } // const whitelist = scopeMap[currentContext]?.whitelist || []; const blacklist = scopeMap[currentContext]?.blacklist || [];