Skip to content

Auto-unindent end #7282

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

Closed
wants to merge 5 commits into from
Closed

Conversation

nicolasstucki
Copy link
Contributor

Based on #7278
Auto-unindent completed end folowed by while, for, match, try, if.

Example:

if a then 
  b
else
  c
  end i
if a then 
  b
else
  c
end if

smarter and others added 4 commits September 20, 2019 14:49
- do not auto-indent after end marker (fixes scala#7274)
- auto-indent after `if ...` as long as it doesn't match `if ... then
  ...` in anticipation of scala#7276
- use lazy matching (`.*?` instead of `.*`) when possible to avoid
  backtracking explosion.
Auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if`
"increaseIndentPattern":
/(((?<!\bend\b\s*?)\b(if|while|for|match|try))|(\bif\s+(?!.*?\bthen\b.*?$)[^\s]*?)|(\b(then|else|do|catch|finally|yield|case))|=|=>|<-|=>>)\s*?$/,
// Only auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if`
"decreaseIndentPattern": /(\bend\b\s*)\b(if|while|for|match|try)$/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a check that there's only spaces on the line before end, use ^\s*end instead of \bend.
Also to get this into the next vscode-dotty release, I would have to rebase my branch to include this commit before the release commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should put this in the release.

How pressing is the release? I also found a couple of annoying integration with then+enter and auto-completion.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not pressing

I also found a couple of annoying integration with then+enter and auto-completion.

I saw that too, but I think that can only be fixed on the language server side, not the vscode extension side

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could fix it by adding the keywords as template suggestions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though the language server could recommend more precise completion

@smarter
Copy link
Member

smarter commented Sep 23, 2019

Cherry-picked in #7278

@smarter smarter closed this Sep 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants