Skip to content

Commit

Permalink
Fixing spawn() for large outputs but leaving several questions about …
Browse files Browse the repository at this point in the history
…the fix
  • Loading branch information
João Pinto committed Mar 27, 2018
1 parent cd4444e commit 503d8c1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 15 additions & 2 deletions src/AsciiDocProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,22 @@ export default class AsciiDocProvider implements TextDocumentContentProvider {
errorMessage += "Go to `File -> Preferences -> User settings` and adjust the AsciiDoc.asciidoctor_command</b>"
resolve(this.errorSnippet(errorMessage));
})

var result_data = ''
asciidoctor.stdout.on('data', (data) => {
let result = this.fixLinks(data.toString(), doc.fileName);
resolve(this.buildPage(result));
const string_data = data.toString();
const received_len = Buffer.byteLength(string_data);
/* This seems to work for large outputs, but several questions remains:
Is there a 64k limit from nodejs in the data received ?
Or is it depend on the ascidoctor output buffering/flush mechanism ?
Will the concatenation work across multiple async stdout.on calls ?
*/
if(received_len < 65536)
{
resolve(this.buildPage(this.fixLinks(result_data + string_data, doc.fileName)));
}
else
result_data += string_data
});
asciidoctor.stdin.write(text);
asciidoctor.stdin.end();
Expand Down
2 changes: 1 addition & 1 deletion test/samples/simple.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Preview as you type, including formatting like *this*, or _this_.
== You can also add your custom CSS style
It will automatically refresh, just as you type

== Heading level 2kv
== Heading level 2
Diferrente heading levels are easly procuded with the # symbol .
You can also do _italic_ or *bold* like in the more common mark down.

Expand Down

0 comments on commit 503d8c1

Please sign in to comment.