Skip to content

Commit ac4e8b9

Browse files
authored
Merge pull request #7278 from dotty-staging/vscode-end-marker
vscode-dotty: Improve auto-indentation
2 parents 85fda0f + 7f2d6c5 commit ac4e8b9

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ object Build {
10631063
lazy val `vscode-dotty` = project.in(file("vscode-dotty")).
10641064
settings(commonSettings).
10651065
settings(
1066-
version := "0.1.16-snapshot", // Keep in sync with package.json
1066+
version := "0.1.17-snapshot", // Keep in sync with package.json
10671067
autoScalaLibrary := false,
10681068
publishArtifact := false,
10691069
includeFilter in unmanagedSources := NothingFilter | "*.ts" | "**.json",

vscode-dotty/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vscode-dotty/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "dotty",
33
"displayName": "Dotty Language Server",
44
"description": "IDE integration for Dotty, the experimental Scala compiler",
5-
"version": "0.1.16-snapshot",
5+
"version": "0.1.17-snapshot",
66
"license": "BSD-3-Clause",
77
"publisher": "lampepfl",
88
"repository": {

vscode-dotty/src/extension.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,14 @@ export function activate(context: ExtensionContext) {
5454
// package.json does not work)
5555
vscode.languages.setLanguageConfiguration("scala", {
5656
"indentationRules": {
57-
// Auto-indent when pressing enter on a line matching this regexp
58-
"increaseIndentPattern": /(((\b(then|else|do|catch|finally|yield|match|while|try|for|if|case)\b)|\bif\s*\(.*\)|=|=>|<-|=>>)\s*$)/,
59-
// Auto-unindent disabled, because it doesn't work well with all
60-
// indentation styles
61-
"decreaseIndentPattern": /^.$/
57+
// Auto-indent when pressing enter on a line matching this regexp, in details:
58+
// 1. If they're not preceded by `end`, auto-indent after `while`, `for`, `match`, `try`, `if`
59+
// 2. Auto-indent after `if ...` as long as it doesn't match `if ... then ...`
60+
// 3. Auto-indent after `then`, `else`, `do`, `catch`, `finally`, `yield`, `case`, `=`, `=>`, `<-`, `=>>`x
61+
"increaseIndentPattern":
62+
/(((?<!\bend\b\s*?)\b(if|while|for|match|try))|(\bif\s+(?!.*?\bthen\b.*?$)[^\s]*?)|(\b(then|else|do|catch|finally|yield|case))|=|=>|<-|=>>)\s*?$/,
63+
// Only auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if`
64+
"decreaseIndentPattern": /(^\s*end\b\s*)\b(if|while|for|match|try)$/
6265
}
6366
})
6467

0 commit comments

Comments
 (0)