From 49e45bba7872bd051851ac41780a4c27b18d7ca8 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:01:07 +0200 Subject: [PATCH 1/5] vscode-dotty: Improve auto-indentation - do not auto-indent after end marker (fixes #7274) - auto-indent after `if ...` as long as it doesn't match `if ... then ...` in anticipation of https://github.com/lampepfl/dotty/pull/7276 - use lazy matching (`.*?` instead of `.*`) when possible to avoid backtracking explosion. --- vscode-dotty/src/extension.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vscode-dotty/src/extension.ts b/vscode-dotty/src/extension.ts index cbf4baad64ae..a7ac7dd1b9f5 100644 --- a/vscode-dotty/src/extension.ts +++ b/vscode-dotty/src/extension.ts @@ -54,8 +54,12 @@ export function activate(context: ExtensionContext) { // package.json does not work) vscode.languages.setLanguageConfiguration("scala", { "indentationRules": { - // Auto-indent when pressing enter on a line matching this regexp - "increaseIndentPattern": /(((\b(then|else|do|catch|finally|yield|match|while|try|for|if|case)\b)|\bif\s*\(.*\)|=|=>|<-|=>>)\s*$)/, + // Auto-indent when pressing enter on a line matching this regexp, in details: + // 1. If they're not preceded by `end`, auto-indent after `while`, `for`, `match`, `try`, `if` + // 2. Auto-indent after `if ...` as long as it doesn't match `if ... then ...` + // 3. Auto-indent after `then`, `else`, `do`, `catch`, `finally`, `yield`, `case`, `=`, `=>`, `<-`, `=>>`x + "increaseIndentPattern": + /(((?|<-|=>>)\s*?$/, // Auto-unindent disabled, because it doesn't work well with all // indentation styles "decreaseIndentPattern": /^.$/ From 6c9bd752d4d466856848241761c9dd504244df46 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:48:52 +0200 Subject: [PATCH 2/5] vscode-dotty: Release 0.1.16 --- project/Build.scala | 2 +- vscode-dotty/package-lock.json | 2 +- vscode-dotty/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 754f9984a7f3..4112965b1d8a 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1061,7 +1061,7 @@ object Build { lazy val `vscode-dotty` = project.in(file("vscode-dotty")). settings(commonSettings). settings( - version := "0.1.16-snapshot", // Keep in sync with package.json + version := "0.1.16", // Keep in sync with package.json autoScalaLibrary := false, publishArtifact := false, includeFilter in unmanagedSources := NothingFilter | "*.ts" | "**.json", diff --git a/vscode-dotty/package-lock.json b/vscode-dotty/package-lock.json index f5d145280186..663361d438c1 100644 --- a/vscode-dotty/package-lock.json +++ b/vscode-dotty/package-lock.json @@ -1,6 +1,6 @@ { "name": "dotty", - "version": "0.1.16-snapshot", + "version": "0.1.16", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/vscode-dotty/package.json b/vscode-dotty/package.json index cc2bcf284f40..34ae6193cd82 100644 --- a/vscode-dotty/package.json +++ b/vscode-dotty/package.json @@ -2,7 +2,7 @@ "name": "dotty", "displayName": "Dotty Language Server", "description": "IDE integration for Dotty, the experimental Scala compiler", - "version": "0.1.16-snapshot", + "version": "0.1.16", "license": "BSD-3-Clause", "publisher": "lampepfl", "repository": { From abbdb7c85e86520169ec7c9123f989d1ea953811 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:49:24 +0200 Subject: [PATCH 3/5] vscode-dotty: Bump to 0.1.17-snapshot --- project/Build.scala | 2 +- vscode-dotty/package-lock.json | 2 +- vscode-dotty/package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 4112965b1d8a..bb464228f6f8 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1061,7 +1061,7 @@ object Build { lazy val `vscode-dotty` = project.in(file("vscode-dotty")). settings(commonSettings). settings( - version := "0.1.16", // Keep in sync with package.json + version := "0.1.17-snapshot", // Keep in sync with package.json autoScalaLibrary := false, publishArtifact := false, includeFilter in unmanagedSources := NothingFilter | "*.ts" | "**.json", diff --git a/vscode-dotty/package-lock.json b/vscode-dotty/package-lock.json index 663361d438c1..22e232900f01 100644 --- a/vscode-dotty/package-lock.json +++ b/vscode-dotty/package-lock.json @@ -1,6 +1,6 @@ { "name": "dotty", - "version": "0.1.16", + "version": "0.1.17-snapshot", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/vscode-dotty/package.json b/vscode-dotty/package.json index 34ae6193cd82..cfe21954fa92 100644 --- a/vscode-dotty/package.json +++ b/vscode-dotty/package.json @@ -2,7 +2,7 @@ "name": "dotty", "displayName": "Dotty Language Server", "description": "IDE integration for Dotty, the experimental Scala compiler", - "version": "0.1.16", + "version": "0.1.17-snapshot", "license": "BSD-3-Clause", "publisher": "lampepfl", "repository": { From 9af90d12d450408ee298c68e3565f6d3885d5997 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 21 Sep 2019 12:31:44 +0200 Subject: [PATCH 4/5] Auto-unindent `end` Auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if` --- vscode-dotty/src/extension.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/vscode-dotty/src/extension.ts b/vscode-dotty/src/extension.ts index a7ac7dd1b9f5..2e46666d453f 100644 --- a/vscode-dotty/src/extension.ts +++ b/vscode-dotty/src/extension.ts @@ -60,9 +60,8 @@ export function activate(context: ExtensionContext) { // 3. Auto-indent after `then`, `else`, `do`, `catch`, `finally`, `yield`, `case`, `=`, `=>`, `<-`, `=>>`x "increaseIndentPattern": /(((?|<-|=>>)\s*?$/, - // Auto-unindent disabled, because it doesn't work well with all - // indentation styles - "decreaseIndentPattern": /^.$/ + // Only auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if` + "decreaseIndentPattern": /(\bend\b\s*)\b(if|while|for|match|try)$/ } }) From a68daa95c086fa5aa250f4d37d913c8444f86b35 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sun, 22 Sep 2019 11:26:13 +0200 Subject: [PATCH 5/5] Only unindent if else is on its own line with spaces before it --- vscode-dotty/src/extension.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode-dotty/src/extension.ts b/vscode-dotty/src/extension.ts index 2e46666d453f..1ce5e52275f0 100644 --- a/vscode-dotty/src/extension.ts +++ b/vscode-dotty/src/extension.ts @@ -61,7 +61,7 @@ export function activate(context: ExtensionContext) { "increaseIndentPattern": /(((?|<-|=>>)\s*?$/, // Only auto-unindent completed `end` folowed by `while`, `for`, `match`, `try`, `if` - "decreaseIndentPattern": /(\bend\b\s*)\b(if|while|for|match|try)$/ + "decreaseIndentPattern": /(^\s*end\b\s*)\b(if|while|for|match|try)$/ } })