Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error text encoding problem. #2

Open
heroboy opened this issue Jul 30, 2020 · 6 comments
Open

Error text encoding problem. #2

heroboy opened this issue Jul 30, 2020 · 6 comments
Labels
bug Something isn't working

Comments

@heroboy
Copy link

heroboy commented Jul 30, 2020

see the screenshot,
not error itself, but the text.
图片

@dsherret
Copy link
Member

Strange. Does it always happen or only on certain repos? Also, what OS are you using?

@heroboy
Copy link
Author

heroboy commented Jul 30, 2020

This may happen I doesn't install the dprint cli when I install the extension.
OS: window 10

@dsherret dsherret added the bug Something isn't working label Jul 30, 2020
@dsherret
Copy link
Member

@heroboy cool. Thanks! I opened #3.

@heroboy
Copy link
Author

heroboy commented Jul 30, 2020

I guess you doesn't consider the stdout's encoding.
If the dprint is not installed, the output will be

'dprint' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

on my machine.

function execShell(
command: string,
stdin: string | undefined,
token: vscode.CancellationToken | undefined,
): Promise<string> {
return new Promise<string>((resolve, reject) => {
let cancellationDisposable: vscode.Disposable | undefined;
try {
const process = exec(command, { cwd: vscode.workspace.rootPath }, (err, stdout, stderr) => {
if (err) {
cancellationDisposable?.dispose();
reject(stderr);
return;
}
resolve(stdout.replace(/\r?\n$/, "")); // remove the last newline
cancellationDisposable?.dispose();
});
cancellationDisposable = token?.onCancellationRequested(() => process.kill());
if (stdin != null) {
process.stdin!.write(stdin);
process.stdin!.end();
}
} catch (err) {
reject(err);
cancellationDisposable?.dispose();
}
});
}

@dsherret
Copy link
Member

Thanks for the info! That was helpful.

@dsherret
Copy link
Member

As per discussion in commit, reopening.

@dsherret dsherret reopened this Jul 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants