refactor(editor): Update Code node editor for native Python runner (#18538)

This commit is contained in:
Iván Ovejero
2025-08-19 13:40:02 +02:00
committed by GitHub
parent 5c53c22d0a
commit fabbddefdc
7 changed files with 52 additions and 18 deletions

View File

@@ -24,7 +24,20 @@ export const useCompleter = (
mode: MaybeRefOrGetter<CodeExecutionMode>,
editor: MaybeRefOrGetter<EditorView | null>,
) => {
function autocompletionExtension(language: 'javaScript' | 'python'): Extension {
function autocompletionExtension(language: 'javaScript' | 'python' | 'pythonNative'): Extension {
if (language === 'pythonNative') {
const completions = (context: CompletionContext): CompletionResult | null => {
const word = context.matchBefore(/\w*/);
if (!word) return null;
const label = toValue(mode) === 'runOnceForEachItem' ? '_item' : '_items';
return { from: word.from, options: [{ label, type: 'variable' }] };
};
return autocompletion({ icons: false, override: [completions] });
}
// Base completions
const { baseCompletions, itemCompletions, nodeSelectorCompletions } = useBaseCompletions(
toValue(mode),