Only strip the trailing source location from messages - #57
Merged
Merged
Conversation
The filter removed every ' on ' and ' in ' in the message, turning 'Cannot use isset() on the result of an expression' into 'Cannot use isset()the result of an expression' and "'break' not in the 'loop' or 'switch' context" into "'break' notthe 'loop' or 'switch' context". Only the trailing ' in Standard input code' / ' in -' that PHP appends should go. Add tests for messages that contain ' on ' and ' in '. Fixes SublimeLinter#55 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Member
|
Looks legit. |
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.
Fixes #55.
_filter_message()replaced everyonandinin the message, so ordinary PHP messages were garbled, e.g.Cannot use isset() on the result of an expressionbecameCannot use isset()the result of an expression, and'break' not in the 'loop' or 'switch' contextbecame'break' notthe 'loop' or 'switch' context.As you said in the issue, only the trailing
in Standard input code/in -(what PHP appends andregexlets through inmessage) should be removed. This replaces the fourreplace()calls with one regex anchored at the end of the message:I added a test,
test_issue_55_message_filter_only_strips_trailing_source, with three messages fromphp -lon PHP 8.4 (theisset()one, thebreakone, andCannot redeclare f() (previously declared in Standard input code:2), where thein Standard input code:2inside the parentheses now stays since it is not trailing). I ran the test module with UnitTesting in Sublime Text 4215: the new test fails before the change (with the garbled text above) and all four tests pass after it, including the three existing ones.One behaviour change to be aware of: a standalone
onthat is not at the end is no longer removed.regexalready consumes theon line Npart, so I could not find a case where the old replacement was needed, but if you know of one, tell me and I'll add a test for it.