Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/custom-snippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ export type CustomREPLCommandSnippet = {
snippet: string;
repl?: string;
ns?: string;
evaluationSendCodeToOutputWindow?: boolean;
pingPong?: boolean;
};

type SnippetDefinition = {
snippet: string;
ns: string;
repl: string;
evaluationSendCodeToOutputWindow?: boolean;
pingPong?: boolean;
};

export function evaluateCustomCodeSnippetCommand(codeOrKeyOrSnippet?: string | SnippetDefinition) {
Expand Down Expand Up @@ -74,7 +77,12 @@ async function evaluateCodeOrKeyOrSnippet(codeOrKeyOrSnippet?: string | SnippetD
nsForm,
snippetDefinition.repl
);
await evaluateCodeInContext(editor, snippetDefinition.snippet, context, options);
const result = await evaluateCodeInContext(editor, snippetDefinition.snippet, context, options);

if (snippetDefinition.pingPong) {
console.log('pingPong', result);
await evaluateCodeInContext(editor, result, context, options);
}
}

async function evaluateCodeInContext(
Expand Down Expand Up @@ -119,6 +127,8 @@ async function getSnippetDefinition(codeOrKey: string, editorNS: string, editorR
description: `${entry.repl}`,
repl: `${entry.repl}`,
snippet: entry.snippet,
pingPong: entry.pingPong,
evaluationSendCodeToOutputWindow: entry.evaluationSendCodeToOutputWindow,
};
snippetsMenuItems.push(item);
if (!snippetsDict[entry.key]) {
Expand Down
3 changes: 3 additions & 0 deletions src/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ async function evaluateCodeUpdatingUI(
await session.evaluateInNs(options.nsForm, outputWindow.getNs());
}

console.log('evaluateCodeUpdatingUI CODE', code);

const context: NReplEvaluation = session.eval(code, ns, {
file: filePath,
line: line + 1,
Expand All @@ -139,6 +141,7 @@ async function evaluateCodeUpdatingUI(
value = util.stripAnsi(context.pprintOut || value);

result = value;
console.log('evaluateCodeUpdatingUI RESULT', result);

flareHandler.inspect(value, (code) => evaluateCodeUpdatingUI(code, options, selection));

Expand Down