Skip to content

Commit

Permalink
Fix issue redhat-developer#2319: Open Java extension log doesn't open…
Browse files Browse the repository at this point in the history
… latest file

Signed-off-by: Quan Zhuo <[email protected]>
  • Loading branch information
quanzhuo committed Feb 20, 2022
1 parent 8aadf21 commit a4d5684
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,19 @@ function openClientLogFile(logFile: string, column: ViewColumn = ViewColumn.Acti
// find out the newest one
glob(filename + '.*', { cwd: dirname }, (err, files) => {
if (!err && files.length > 0) {
files.sort();
files.sort((a, b) => {
const dateA = a.slice(11, 21), dateB = b.slice(11, 21);
if (dateA === dateB) {
if (a.length > 22 && b.length > 22) {
const extA = a.slice(22), extB = b.slice(22);
return parseInt(extA) - parseInt(extB);
} else {
return a.length - b.length;
}
} else {
return dateA < dateB ? -1 : 1;
}
});
logFile = path.join(dirname, files[files.length - 1]);
}

Expand Down

0 comments on commit a4d5684

Please sign in to comment.