Fix: Add syntax highlighting for model= named arguments in NeuronGroup/Synapses#12
Fix: Add syntax highlighting for model= named arguments in NeuronGroup/Synapses#12Mohamed-Sobea wants to merge 2 commits into
Conversation
|
Hi @Mohamed-Sobea, thanks for the PR. I did not yet look at it in detail, but just one small remark:
Equations cannot contain any quotes (escaped or not), so I don't think we need to account for this possibility. |
Ah that makes sense. I was applying general Python string parsing rules and didn't consider that valid Brian mathematical equations wouldn't contain string literals/quotes in the first place. |
This PR implements the first part of the fix for Issue #11 by adding support for named arguments (model=).
I have updated brian.injection.json to correctly trigger the source.brian scope when equations are passed via the keyword argument.
Technical Details:
Handles all four Python string quote types (""", ''', ", ').
Accounts for the spurious whitespace you mentioned (e.g., model = "..." vs model="...").
Uses negative lookbehinds (?<!\) to ensure escaped quotes inside the equations don't accidentally break the highlighting scope.
(Note: I have left a comment on the main issue thread regarding my findings on the positional arguments and the AST approach)
Screenshot of working tests: