-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Auto-unindent end #7282
Conversation
- 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`
vscode-dotty/src/extension.ts
Outdated
"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)$/ |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Cherry-picked in #7278 |
Based on #7278
Auto-unindent completed
end
folowed bywhile
,for
,match
,try
,if
.Example: