fix: Fix SyntaxHighlighter glob pattern handling for non-default file systems by gnodet · Pull Request #1300 · jline/jline3 (original) (raw)
gnodet changed the title
Fix SyntaxHighlighter glob pattern handling for non-default file systems fix: Fix SyntaxHighlighter glob pattern handling for non-default file systems
…rrectly
The original implementation had several issues when processing glob patterns in nanorc include/theme directives:
- Called nanorc.resolveSibling(parameter).getParent() with glob patterns containing wildcards, which fails on Windows and non-default file systems
- Did not properly support recursive patterns like 'foo/bar/**/*.nanorc'
- Used Paths.get() which assumes the default file system, breaking compatibility with JAR file systems
Changes:
- Refactored addFiles method to extract static path prefix and glob pattern separately using new PathParts helper class
- Use nanorc.resolveSibling() consistently for path resolution to support non-default file systems like JAR FS
- Avoid path normalization and let the file system handle path separators
- Added comprehensive tests with JimFS to verify cross-platform behavior on both Unix and Windows file systems
The fix ensures that nanorc configuration files can properly include syntax files using glob patterns like:
- '*.nanorc' (simple patterns)
- 'subdir/*.nanorc' (subdirectory patterns)
- 'foo/bar/**/*.nanorc' (recursive patterns)
- '/usr/share/nano/*.nanorc' (absolute patterns)
Fixes #1290
gnodet deleted the fix-syntax-highlighter-glob-patterns branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})