Skip to content

Update function pattern to explicitly capture blocks inside functions #1

@ideabucket

Description

@ideabucket

Currently the function pattern matches up function and end keywords by looking for an end that is indented to the same level as the opening function.

This is brittle as all get-out—it will, for example, break if one half of the pair is indented with tabs and the other with spaces—and, ideally, should be changed.

In theory, since the number of fish language constructs which are terminated by end is fairly small, it should be possible to define a subpattern which explicitly captures those constructs inside function_body, thereby preventing them from being matched as candidates for function_terminator.

However, there are two problems:

  1. It's unclear how to handle nested blocks, e.g.:
     function foobar
         for i in $argv
             if test $argv[i] = "top sekrit"
                 echo "ssssssh!"
             end
         end
     end
  2. This is getting perilously close to parsing HTML with regex, and nobody wants eldritch abominations in their syntax highlighting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions