Skip to content

Commit d8a989b

Browse files
quanzhuorgrunber
authored andcommitted
Fix issue #2319: Open Java extension log doesn't open latest file
Signed-off-by: Quan Zhuo <[email protected]>
1 parent 3ad9749 commit d8a989b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,19 @@ function openClientLogFile(logFile: string, column: ViewColumn = ViewColumn.Acti
727727
// find out the newest one
728728
glob(filename + '.*', { cwd: dirname }, (err, files) => {
729729
if (!err && files.length > 0) {
730-
files.sort();
730+
files.sort((a, b) => {
731+
const dateA = a.slice(11, 21), dateB = b.slice(11, 21);
732+
if (dateA === dateB) {
733+
if (a.length > 22 && b.length > 22) {
734+
const extA = a.slice(22), extB = b.slice(22);
735+
return parseInt(extA) - parseInt(extB);
736+
} else {
737+
return a.length - b.length;
738+
}
739+
} else {
740+
return dateA < dateB ? -1 : 1;
741+
}
742+
});
731743
logFile = path.join(dirname, files[files.length - 1]);
732744
}
733745

0 commit comments

Comments
 (0)