Skip to content

Commit

Permalink
fix anonymous functions as arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
watermarkhu committed Jun 15, 2024
1 parent ba83c5e commit 467e6ff
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Matlab.tmbundle/Syntaxes/MATLAB.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
<key>begin</key>
<string>(?&lt;=\))[^\S\n]*(\()?</string>
<key>end</key>
<string>(\))?[^\S\n]*(?=;|(?&lt;!(?:\.{3}.*))\n|%)</string>
<string>(\))?[^\S\n]*(?=;|,|(?&lt;!(?:\.{3}.*))\n|%)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down Expand Up @@ -262,7 +262,7 @@
</dict>
</array>
<key>end</key>
<string>(?=;|(?&lt;!(?:\.{3}.*))\n|%)</string>
<string>(?=;|,|(?&lt;!(?:\.{3}.*))\n|%)</string>
</dict>
<key>blocks</key>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion test/t54LineContinuationInAnonymousFunctions.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% SYNTAX TEST "source.matlab" "Imports: https://github.com/mathworks/MATLAB-Language-grammar/pull/52"
% SYNTAX TEST "source.matlab" "LineContinationInAnonymousFunctions: https://github.com/mathworks/MATLAB-Language-grammar/pull/52"


@(x, y) x.^2+y;
Expand Down
2 changes: 1 addition & 1 deletion test/t57Operators.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% SYNTAX TEST "source.matlab" "Imports: https://github.com/mathworks/MATLAB-Language-grammar/pull/57"
% SYNTAX TEST "source.matlab" "Operators: https://github.com/mathworks/MATLAB-Language-grammar/pull/57"

%% Assignment and metadata query

Expand Down
2 changes: 1 addition & 1 deletion test/t61ReadWriteOperations.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
% SYNTAX TEST "source.matlab" "Imports: https://github.com/mathworks/MATLAB-Language-grammar/pull/51"
% SYNTAX TEST "source.matlab" "ReadWriteOperations: https://github.com/mathworks/MATLAB-Language-grammar/pull/51"

variable
% <------- variable.other.readwrite.matlab
Expand Down
23 changes: 23 additions & 0 deletions test/t80AnonymousFunctionArgument.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
% SYNTAX TEST "source.matlab" "AnonymousFunctionArgument: https://github.com/mathworks/MATLAB-Language-grammar/pull/51"

q = integral(@(x) x.^2, 0, 1);
% ^^^^^^^^^ meta.function.anonymous.matlab
% ^ - meta.function.anonymous.matlab


if ~isempty(lstr)
p.DataTipTemplate.DataTipRows(end+1) = ...
dataTipTextRow('cBin', arrayfun(@(x) lstr, binsX, 'UniformOutput', false));
% ^^^^^^^^^ meta.function.anonymous.matlab
% ^ - meta.function.anonymous.matlab
end
% <-- meta.if.matlab keyword.control.end.if.matlab


if ~isempty(lstr)
p.DataTipTemplate.DataTipRows(end+1) = ...
dataTipTextRow('cBin', arrayfun(@(x) lstr, binsX, 'UniformOutput', false));
% ^^^^^^^^^ meta.function.anonymous.matlab
% ^ - meta.function.anonymous.matlab
end
% <-- meta.if.matlab keyword.control.end.if.matlab

0 comments on commit 467e6ff

Please sign in to comment.