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

Update indent pattern #231

Merged
merged 8 commits into from
Jan 24, 2018
Merged

Update indent pattern #231

merged 8 commits into from
Jan 24, 2018

Conversation

TeeSeal
Copy link
Contributor

@TeeSeal TeeSeal commented Dec 12, 2017

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
Copy link
Contributor Author

TeeSeal commented Dec 15, 2017

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
Collaborator

ping @rebornix

@wingrunr21
Copy link
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
Copy link
Contributor Author

TeeSeal commented Jan 22, 2018

@wingrunr21 okay, will do!

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

@TeeSeal your PR LGTM, thanks for your contribution.

@wingrunr21
Copy link
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
Copy link
Contributor Author

TeeSeal commented Jan 25, 2018

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

@TeeSeal
Copy link
Contributor Author

TeeSeal commented Jan 25, 2018

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
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