Skip to content
Snippets Groups Projects
Commit 8c2e7314 authored by Robin Leber's avatar Robin Leber
Browse files

pipe binding with multiple editor opening

parent 107c3ad6
No related branches found
No related tags found
No related merge requests found
......@@ -20,18 +20,27 @@ export const getPipesForFilter = () => {
export const handlePipeBinding = (pipeMapping, editor) => {
let lineNumber = 14;
let editorCodeText = editor.state.doc.toString();
pipeMapping.forEach((pipe) => {
let line = editor.state.doc.line(lineNumber);
let position = line.from;
let transaction = editor.state.update({
changes: {
from: position,
insert: `\t\tconst ${pipe.pipeName.replace(/\s+/g, "")} = "${
pipe.pipeName
}"\n`,
},
});
editor.dispatch(transaction);
lineNumber++;
if (
editorCodeText.includes(
`const ${pipe.pipeName.replace(/\s+/g, "")} = "${pipe.pipeName}"`
)
) {
return;
} else {
let line = editor.state.doc.line(lineNumber);
let position = line.from;
let transaction = editor.state.update({
changes: {
from: position,
insert: `\t\tconst ${pipe.pipeName.replace(/\s+/g, "")} = "${
pipe.pipeName
}"\n`,
},
});
editor.dispatch(transaction);
lineNumber++;
}
});
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment