A line like function y = foo(a, b, c) should yield a tag of foo, not foo(a, b, c).
That way, Ctrl-clicking foo somewhere in the code will take me there.
The function name is foo after all, not foo(a, b c).

Also, fixed issue where a line like function foo() % this = bug would yield a tag of bug instead of foo because the = in the comment was not ignored.

Finally, added a check to ensure that the line starts with the keyword function, and not any word starting with function... which could be a variable name (e.g. functionality).

Here I am considering that function names contain only alphanumeric characters (and underscore) as Matlab's documentation states. I'm not aware of the possibility of declaring functions with . or other special characters directly using function.

Example Matlab file demonstrating the issue:

function y = foo(a, b, c) % the function name should be `foo`, not `foo(a, b, c)`
    y = a+b+c;
end
function baz() % this = bug
    disp('The function name is `baz`, not `bug`');
end
functionality = struct('a', 1, 'b', 2);

This used to yield tags foo(a, b, c) and bug, as well as struct('a', 1, 'b', 2); as a function; now it yields tags foo and baz as expected, and omits the functionality thing.

(If it's any consolation, notice that GitHub also messes up the highlighting of baz() because of the = in the comment.)


PS: Similarly, it might be good to figure out a way to also exclude occurrences of the substring "struct" that aren't the keyword struct itself, such as in strings, or as part of words, e.g.:

restructure = true;
disp('You are on the way to destruction.');

You can view, comment on, or merge this pull request online at:

  https://github.com/geany/geany/pull/3358

Commit Summary

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <geany/geany/pull/3358@github.com>