Phidica / sublime-fish

A robust Sublime Text syntax package for fish
MIT License
35 stars 2 forks source link

got hang up problem #14

Closed rainchen closed 6 years ago

rainchen commented 6 years ago

sublime will often hang up when using this package to write fish codes.

hang up which means CPU's usage is 100% then not responding, I have to kill the sublime process to force quit.

for example, following codes will make my sublime hang up:

function crash

  # going to rewrite it to fish code
  function name {
    help_message="help message, usage example: name"
    if [[ $# -eq 0 ]]; then
      echo $help_message
    else
      code=$1
      if [ "$code" == '--help' ]; then
        echo $help_message
      else
        echo "param: $code"
      fi
    fi
  }

end

my sublime version is v2.0.2

Any idea?

Phidica commented 6 years ago

Oh, this is interesting. The issue doesn't appear in ST3, however I tried your example script in ST2 and indeed saw the same result. I narrowed the cause down to the appearance of any operator (;, &, |, etc) appearing somewhere in a set of curly braces { }. The match seeking unquoted strings within brace expansion appears to fall into an infinite loop in ST2. Presumably, some change in the regex engine for ST3 stops this from hanging the entire program.

I've determined a fix that solves the issue in ST2 and doesn't change any intended behaviour in ST3. If you continue to have this problem please reopen this issue. If you encounter a different but similar problem, please open a new issue.

rainchen commented 6 years ago

thx for your quick response, it works.

but after some more testing, it still failing with these codes:

# A minimalist package manager for fish shell
# https://github.com/tuvistavie/fundle

function __fundle_url_rev -d "prints the revision from the url" -a git_url
  set -l rev (echo $git_url | cut -d '#' -f 2 -s)
  if test -n "$rev"
    echo $rev
  else
    echo master
  end
end

These codes look quite normal fish code to me. They come from https://github.com/tuvistavie/fundle/blob/master/functions/fundle.fish I didn't test all of them, btw.

Phidica commented 6 years ago

Sorry about these issues; I never tested the syntax in ST2 but I really should have if I was going to claim ST2 compatibility. I'll continue working on fixes until I'm convinced that the syntax works correctly in ST2.

Phidica commented 6 years ago

@rainchen Could you try the latest version, 2.2.5, in ST2? I've confirmed it works on all syntax tests I've written, as well as the example scripts you linked. Please let me know if you find any other examples that lead to a hang.

rainchen commented 6 years ago

@Phidica updated to 2.2.5. found it still hanging with these codes: https://raw.githubusercontent.com/oh-my-fish/theme-jacaetevha/master/fish_prompt.fish

Phidica commented 6 years ago

Thanks for your patience. Could you try again now, with version 2.2.6?

rainchen commented 6 years ago

works fine now. Good jobs!

Phidica commented 6 years ago

Thank you :) I'll leave this issue open a little longer and close it if nothing else comes up