Skip to content

Commit

Permalink
Hopefully fixs regression with use_asciidoctor_js='False'- Thanks to @…
Browse files Browse the repository at this point in the history
…danyill for the test'
  • Loading branch information
João Pinto committed Mar 26, 2018
1 parent 9f04dad commit 43faf6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
"type": "object",
"title": "AsciiDoc Option Configuration",
"properties": {
"AsciiDoc.buffer_size_kB": {
"type": "number",
"default": 200,
"description": "Maximum size of output buffer from preview command in kB. Increase if you receive a stdout maxBuffer exceeded error"
},
"AsciiDoc.asciidoctor_binary_path": {
"type": "string",
"default": "asciidoctor",
Expand Down
5 changes: 3 additions & 2 deletions src/AsciiDocProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export default class AsciiDocProvider implements TextDocumentContentProvider {

public preview(doc: TextDocument): Thenable<string> {
let use_asciidoctor_js = workspace.getConfiguration('AsciiDoc').get('use_asciidoctor_js');

let text = doc.getText();
let documentPath = path.dirname(doc.fileName);

Expand Down Expand Up @@ -160,8 +161,8 @@ export default class AsciiDocProvider implements TextDocumentContentProvider {
})
} else
return new Promise<string>((resolve, reject) => {
let asciidoctor_binary_path = workspace.getConfiguration('AsciiDoc').get('asciidoctor_binary_path');
const asciidoctor = spawn('asciidoctor', ['-o-', '-', '-B', path.dirname(doc.fileName)]);
let asciidoctor_binary_path = workspace.getConfiguration('AsciiDoc').get('asciidoctor_binary_path', 'asciidoctor');
var asciidoctor = spawn(asciidoctor_binary_path, ['-o-', '-', '-B', path.dirname(doc.fileName)], { shell: true} );
asciidoctor.stdin.write(text);
asciidoctor.stdin.end();
asciidoctor.stderr.on('data', (data) => {
Expand Down

2 comments on commit 43faf6e

@danyill
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @joaompinto I'm not able to get output in this case and I can't see why.

  • Running a command in a shell with the same parameters works nicely: asciidoctor -o- - -B /some/path < README.adoc

  • No output in the VS code developer tools. I tried to add a console.log statement in the extension code but it did not turn up in the developer tools (and I can't remember how to do it and my google fu is failing)

  • I think there's a path resolution issue with path.dirname(doc.fileName) which seems to work for some paths but not others. So I am sporadically getting output depending on /some/path.
    In particular the path:

    /home/test.adoc works nicely

    A longer path (but without spaces) is breaking:

    /media/veracrypt51/Education/Gitlab/Synchrophasor_Sync_Check_Settings

    When I look at the VS code source, there is no document, but the path appears correct in the <base href= element. So I'm a bit stuck for now. More later!

@joaompinto
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danyill just opening the source with VS code, and then starting in debug (F5) should be sufficient for the console.log, please note that the output is only shown in the primary vscode instance "DEBUG CONSOLE" window, and not in the one running the extension.

Meanwhile I have set the current work directory on spawn(), 7448ab5 , this will have effect if doc.fileName is relative or absolute depending on the way you open a file/folder (just guessing, not sure it makes really a difference).

Please sign in to comment.