Skip to content

Commit b283fb9

Browse files
jdneosnjeza
authored andcommitted
fix the issue that cannot generate the format setting file (#613)
Signed-off-by: Sheng Chen <sheche@microsoft.com>
1 parent 1f67839 commit b283fb9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/extension.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ function openServerLogFile(workspacePath): Thenable<boolean> {
430430
}
431431

432432
async function openFormatter(extensionPath) {
433-
let defaultFormatter = extensionPath + '/formatters/eclipse-formatter.xml';
433+
let defaultFormatter = path.join(extensionPath, 'formatters', 'eclipse-formatter.xml');
434434
let formatterUrl: string = getJavaConfiguration().get('format.settings.url');
435435
if (formatterUrl && formatterUrl.length > 0) {
436436
if (isRemote(formatterUrl)) {
@@ -447,7 +447,7 @@ async function openFormatter(extensionPath) {
447447
let file;
448448
let relativePath;
449449
if (!global) {
450-
file = path.join(workspace.workspaceFolders[0].uri.path, fileName);
450+
file = path.join(workspace.workspaceFolders[0].uri.fsPath, fileName);
451451
relativePath = fileName;
452452
} else {
453453
let root = path.join(extensionPath, '..', 'redhat.java');
@@ -522,7 +522,7 @@ async function addFormatter(extensionPath, formatterUrl, defaultFormatter, relat
522522
if (!path.isAbsolute(f)) {
523523
let fileName = f;
524524
if (!global) {
525-
f = path.join(workspace.workspaceFolders[0].uri.path, fileName);
525+
f = path.join(workspace.workspaceFolders[0].uri.fsPath, fileName);
526526
relativePath = fileName;
527527
} else {
528528
let root = path.join(extensionPath, '..', 'redhat.java');
@@ -541,8 +541,9 @@ async function addFormatter(extensionPath, formatterUrl, defaultFormatter, relat
541541
let action = 'Yes';
542542
window.showWarningMessage(msg, action, 'No').then((selection) => {
543543
if (action === selection) {
544-
fs.createReadStream(defaultFormatter).pipe(fs.createWriteStream(f));
545-
openDocument(extensionPath, f, defaultFormatter, relativePath);
544+
fs.createReadStream(defaultFormatter)
545+
.pipe(fs.createWriteStream(f))
546+
.on('finish', () => openDocument(extensionPath, f, defaultFormatter, relativePath));
546547
}
547548
});
548549
} else {

0 commit comments

Comments
 (0)