slash-create/docs-bot

refactor(`/code *`): rework handling of resulting context

Opened this issue · 0 comments

The construction of the resulting content was purpose built to be passed directly to the returned object as a matching variable, and while that is favourable for a direct pass-through... not so much for the while loop, which repeatedly splits and joins the string until it has been trimmed to size. #47 would be designed to work around this mechanism, but for its own reason.

Intention to rework content as lines which remains held in its array format, so that the while loop can use the array without needing code to split and join.

let content = [
this.generateContentHeader(file, [startLine, actualStart], [endLine, actualEnd]),
[...amendNotes].map((note) => `> ${note}`),
'```ts',
lineSelection.map((line, index) =>
this.generateCodeLine(line, actualStart + index, actualEnd, shouldHaveLineNumbers)
),
'```'
]
.flat()
.join('\n');