Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final `end` does not get highlighted after a block with a rescue inside a method #112

Closed
calebmeyer opened this issue Oct 31, 2019 · 5 comments
Closed
Labels
bug

Comments

@calebmeyer
Copy link

@calebmeyer calebmeyer commented Oct 31, 2019

Description

Ruby 2.6 added the ability to do a rescue without a corresponding begin inside a block. That means code like

arr.each do |thing|
  begin
    try(thing)
  rescue error
    handle_it
  end
end

can be rewritten a little shorter (omitting the begin, and fixing the indentation):

arr.each do |thing|
  try(thing)
rescue error
  handle_it
end

Steps to Reproduce

  1. Put a block like the above into a method

Expected behavior:
All end tags are syntax highlighted

Actual behavior:
The method's end tag loses highlighting:
image

Reproduces how often:
100% of the time

Versions

atom --version

Atom    : 1.40.0
Electron: 3.1.10
Chrome  : 66.0.3359.181
Node    : 10.2.0

apm --version
apm  2.4.2
npm  6.2.0
node 10.2.1 x64
atom 1.40.0
python 3.7.2
git 2.16.2.windows.1
visual studio

OS: Windows 10 Enterprise (1809)

Additional Information

I originally logged this as atom/language-ruby#274

@issue-label-bot issue-label-bot bot added the bug label Oct 31, 2019
@issue-label-bot

This comment has been minimized.

Copy link

@issue-label-bot issue-label-bot bot commented Oct 31, 2019

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.59. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@patrickt

This comment has been minimized.

Copy link
Contributor

@patrickt patrickt commented Oct 31, 2019

Hmm. Definitely doesn’t look like Atom is doing the right thing here. The tree seems plausible:

(program [0, 0] - [5, 0]
  (method_call [0, 0] - [4, 3]
    method: (call [0, 0] - [0, 8]
      receiver: (identifier [0, 0] - [0, 3])
      method: (identifier [0, 4] - [0, 8]))
    block: (do_block [0, 9] - [4, 3]
      (block_parameters [0, 12] - [0, 19]
        (identifier [0, 13] - [0, 18]))
      (method_call [1, 2] - [1, 12]
        method: (identifier [1, 2] - [1, 5])
        arguments: (argument_list [1, 5] - [1, 12]
          (identifier [1, 6] - [1, 11])))
      (rescue [2, 0] - [3, 11]
        exceptions: (exceptions [2, 7] - [2, 12]
          (identifier [2, 7] - [2, 12]))
        body: (then [2, 12] - [3, 11]
          (identifier [3, 2] - [3, 11]))))))
@patrickt

This comment has been minimized.

Copy link
Contributor

@patrickt patrickt commented Oct 31, 2019

Might it be that Atom is using an outdated grammar?

@maxbrunsfeld

This comment has been minimized.

Copy link
Member

@maxbrunsfeld maxbrunsfeld commented Oct 31, 2019

Yeah, I recently fixed this in 575d74b. We need to upgrade tree-sitter-ruby in Atom.

@patrickt

This comment has been minimized.

Copy link
Contributor

@patrickt patrickt commented Oct 31, 2019

Looks like we should close this and reopen atom/language-ruby#274 (or a similar issue re. bumping tree-sitter-ruby).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.