From ffc2f07bb8610804ce60819158042500df276b08 Mon Sep 17 00:00:00 2001 From: Andrew Fichman Date: Fri, 19 Jun 2020 11:52:21 -0400 Subject: [PATCH 1/4] Adds support for ?= operator --- README.md | 6 +++--- src/formatter.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 71cab3a..0495d9d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Better Align -[![Current Version](http://vsmarketplacebadge.apphb.com/version-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) -[![Install Count](http://vsmarketplacebadge.apphb.com/installs-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) -[![Rating](http://vsmarketplacebadge.apphb.com/rating-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) +[![Current Version](https://vsmarketplacebadge.apphb.com/version-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) +[![Install Count](https://vsmarketplacebadge.apphb.com/installs-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) +[![Rating](https://vsmarketplacebadge.apphb.com/rating-short/wwm.better-align.svg)](https://marketplace.visualstudio.com/items?itemName=wwm.better-align) ## Features diff --git a/src/formatter.ts b/src/formatter.ts index eb514d1..62a3b7d 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -201,7 +201,7 @@ export default class Formatter { } else if ( char == "=" && next == "=" ) { currTokenType = TokenType.Word; nextSeek = 2; - } else if (( char == "+" || char == "-" || char == "*" || char == "/" ) && next == "=" ) { + } else if (( char == "+" || char == "-" || char == "*" || char == "/" || char == "?") && next == "=" ) { currTokenType = TokenType.Assignment; nextSeek = 2; } else if ( char == "=" && next != "=" ) { From f2d641bdb0886c6366ec546f6f081d271e6dea79 Mon Sep 17 00:00:00 2001 From: Andrew Fichman Date: Fri, 19 Jun 2020 12:17:18 -0400 Subject: [PATCH 2/4] update comments --- src/formatter.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/formatter.ts b/src/formatter.ts index 62a3b7d..42c3240 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -3,7 +3,7 @@ import * as vscode from "vscode"; enum TokenType { Invalid , Word - , Assignment // = += -= *= /= + , Assignment // = += -= *= /= ?= , Arrow // => , Block // {} [] () , PartialBlock // { [ ( @@ -49,7 +49,7 @@ function whitespace( count ) { export default class Formatter { /* Align: - * operators = += -= *= /= : + * operators = += -= *= /= ?=: * trailling comment * preceding comma * Ignore anything inside a quote, comment, or block From cbaad9aac237818518a7e89642b8f176dcfc51aa Mon Sep 17 00:00:00 2001 From: JulienCa Date: Tue, 21 Jul 2020 12:01:43 +0200 Subject: [PATCH 3/4] Update formatter.ts --- src/formatter.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/formatter.ts b/src/formatter.ts index 42c3240..00e67a5 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -3,7 +3,7 @@ import * as vscode from "vscode"; enum TokenType { Invalid , Word - , Assignment // = += -= *= /= ?= + , Assignment // = += -= *= /= ?= := <= , Arrow // => , Block // {} [] () , PartialBlock // { [ ( @@ -49,7 +49,7 @@ function whitespace( count ) { export default class Formatter { /* Align: - * operators = += -= *= /= ?=: + * operators = += -= *= /= ?= : := <= * trailling comment * preceding comma * Ignore anything inside a quote, comment, or block @@ -201,7 +201,7 @@ export default class Formatter { } else if ( char == "=" && next == "=" ) { currTokenType = TokenType.Word; nextSeek = 2; - } else if (( char == "+" || char == "-" || char == "*" || char == "/" || char == "?") && next == "=" ) { + } else if (( char == "+" || char == "-" || char == "*" || char == "/" || char == "?" || char == ":" || char == "<") && next == "=" ) { currTokenType = TokenType.Assignment; nextSeek = 2; } else if ( char == "=" && next != "=" ) { From 597471ee68d11c0a0a9fe36de90d29c7b05c1ba1 Mon Sep 17 00:00:00 2001 From: JulienCa Date: Tue, 21 Jul 2020 12:03:33 +0200 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0495d9d..d9109e5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ ## Features -Align your code by colon(`:`), assignment(`=`,`+=`,`-=`,`*=`,`/=`) and arrow(`=>`). +Align your code by colon(`:`), assignment(`=`,`+=`,`-=`,`*=`,`/=`,`?=`,`:=`,`<=`) and arrow(`=>`). It has additional support for comma-first coding style and trailing comment. And it doesn't require you to select what to be aligned, the extension will figure it out by itself.