Skip to content

Commit 3f62af3

Browse files
committed
Leave generated templates byte for byte and accept absolute XDG paths on Windows
The template check compares against the library's examples byte for byte, so normalising the CRLF settings.json made it stale; templates are now -text. ProjectsFolder took only /-prefixed XDG paths, which fails for an absolute Windows path.
1 parent 047e38a commit 3f62af3

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

‎.gitattributes‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
# Templates and lessons are copied byte for byte and matched against
22
# multi-line text: keep LF on every platform, including Windows checkouts.
33
* text=auto eol=lf
4+
# Generated from the library's examples and checked byte for byte against
5+
# them (scripts/sync-templates.py --check): never convert.
6+
core/src/main/resources/org/openpatch/scratch4j/core/templates/** -text
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{
2-
"java.project.referencedLibraries": [
3-
"+libs/**/*.jar"
4-
]
5-
}
1+
{
2+
"java.project.referencedLibraries": [
3+
"+libs/**/*.jar"
4+
]
5+
}

‎ui/src/main/java/org/openpatch/scratch4j/ui/ProjectsFolder.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ static Path xdgDocuments(Path userDirs, Path home) {
108108
String rest = value.substring("$HOME".length()).replaceFirst("^/", "");
109109
return rest.isEmpty() ? home : home.resolve(rest);
110110
}
111-
return value.startsWith("/") ? Path.of(value) : null;
111+
Path path = Path.of(value);
112+
return path.isAbsolute() ? path : null;
112113
} catch (IOException | RuntimeException e) {
113114
return null;
114115
}

0 commit comments

Comments
 (0)