From 2113a7b8453f285c3a5062af35ba07b605d77507 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:01:07 +0200 Subject: [PATCH 1/4] 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 c5d15607cd30c3b054fefbf8e4669d811f9a7179 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Sat, 21 Sep 2019 12:31:44 +0200 Subject: [PATCH 2/4] vscode-dotty: 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..1ce5e52275f0 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": /(^\s*end\b\s*)\b(if|while|for|match|try)$/ } }) From 6cbd277127b79a1895990bc88ca184c1eae67b34 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:48:52 +0200 Subject: [PATCH 3/4] 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 fbd2bfcb9ff4..48fc62378cff 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1063,7 +1063,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 7f2d6c5adc7757290c48ccb02f1b36c0edce6aff Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Fri, 20 Sep 2019 14:49:24 +0200 Subject: [PATCH 4/4] 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 48fc62378cff..17c49701ecde 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1063,7 +1063,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": {