Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Update indent pattern - #231

Merged
rebornix merged 8 commits into
rubyide:masterfrom
teeseal:master
Jan 24, 2018
Merged

rebornix merged 8 commits into
rubyide:masterfrom
teeseal:master

Conversation

@teeseal

@teeseal teeseal commented Dec 12, 2017 •

Copy link
Copy Markdown

Refer the following pull request and the issues linked in it:
microsoft/vscode#40049

@rebornix
This PR seems to come into a bit of conflict with #223, should make a decision on which one we're going to use.

Here's the thing:

  1. If case doesn't indent the next line and when doesn't unindent, the indentation will be ok only while we're adding when clauses, but will break when we use else and/or end (because these 2 do unindent). The result of using the changes made in Fix Travis #233 would be this:
  case thing
  when 2 then true
  when 4 then false
else nil
end
  1. With this PR the case statement does indent the next line but any of when, else and end will unindent leading to a desired output:
  case thing
  when 2 then true
  when 4 then false
  else nil
  end

@teeseal

teeseal commented Dec 15, 2017 •

Copy link
Copy Markdown
Author

I also made the changes for private and protected defs the same way they are in the built in extension for Ruby of VS Code. This can now be considered in favor of #223 and #206.

I also edited the [^\{;] part to just [^;]. I didn't see the point of that curly brace there, and it made things such as:

  if string =~ /\d{4}/
  #not indent properly
end

Generally speaking, the semicolon there could also impose the same problem.

EDIT:

Okay, I found a more elegant approach to this. It now takes everything between quotes or / as non-special characters.
Also I updated the .*s to [^#]* to make sure comments are also ignored. It would indent if it found the do word in an inline comment.

Here's the updated behavior:
upgrade

@wingrunr21

Copy link
Copy Markdown
Collaborator

ping @rebornix

@wingrunr21

Copy link
Copy Markdown
Collaborator

Hi @teeseal

Would you be willing to reopen this PR against my fork?

Fork: https://github.com/wingrunr21/vscode-ruby-lang

See #239 (comment) for more information

Thanks!

@teeseal

teeseal commented Jan 22, 2018

Copy link
Copy Markdown
Author

@wingrunr21 okay, will do!

@rebornix
rebornix merged commit b659e1c into rubyide:master Jan 24, 2018
@rebornix

Copy link
Copy Markdown
Member

@teeseal your PR LGTM, thanks for your contribution.

@wingrunr21

Copy link
Copy Markdown
Collaborator

@rebornix

@teeseal made additional updates to that intent and unindent patterns in the PR to my fork. It fixes a few other issues that are still in the patterns in this PR.

wingrunr21/vscode-ruby-lang#9

@teeseal

teeseal commented Jan 25, 2018

Copy link
Copy Markdown
Author

Ye I thought this place is dead so I didn’t bother updating this source branch

@teeseal

teeseal commented Jan 25, 2018

Copy link
Copy Markdown
Author

There are still some issues they are a bit harder to handle, Ill investigate those, see if I can do anything about them and open another PR

@rebornix

Copy link
Copy Markdown
Member

@teeseal thanks, look forward to it ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants