Repository navigation
Fix Bash function list missing functions after a bare "#" comment line - #18527
Open
haraldrohan wants to merge 1 commit into
Open
haraldrohan wants to merge 1 commit into
haraldrohan wants to merge 1 commit into
Conversation
In the Bash parser's commentExpr, "^\x23[^!]" (meant to exclude a "#!" shebang) let "[^!]" consume the line break of a line that contains only "#", so the following ".*$" swallowed the whole next line - e.g. the function header - as part of the comment. This only happens with LF line endings; with CRLF, "[^!]" consumes the "\r" instead. Replaced "[^!]" with the zero-width lookahead "(?!!)", and extended the bash unit test with a function preceded by such a comment block. Fix notepad-plus-plus#18174 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #18174.
In the Bash function-list parser (
PowerEditor/installer/functionList/bash.xml), the single-line comment part ofcommentExpris:On a line containing only
#,[^!](meant to exclude a#!shebang) matches the line break, so.*$swallows the next line. If that line is a function header, the function is missing from the Function List:This only happens with LF line endings (typical for shell scripts). With CRLF,
[^!]consumes the\rand the\nstays intact, so the function is found.Fix
Replaced
[^!]with the zero-width negative lookahead(?!!), which still rejects#!but does not consume any character. No other part of the expression changes.Test plan
PowerEditor/Test/FunctionList/bash/unitTestwith a function preceded by a bare-#comment block; updatedunitTest.expected.result.unitTestLauncher.ps1): all 46 tests pass.notepad++.exe -export=functionList -lbashon the LF example from the issue:errorExitis now listed (before: nothing).Note: with
core.autocrlf=true(as in CI) the test file is checked out with CRLF, where this bug doesn't occur, so the new test case documents the scenario rather than guarding against regressions.🤖 Generated with Claude Code