diff --git a/README.md b/README.md index 71cab3a..d9109e5 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # 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 -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. diff --git a/src/formatter.ts b/src/formatter.ts index eb514d1..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 == "/" ) && next == "=" ) { + } else if (( char == "+" || char == "-" || char == "*" || char == "/" || char == "?" || char == ":" || char == "<") && next == "=" ) { currTokenType = TokenType.Assignment; nextSeek = 2; } else if ( char == "=" && next != "=" ) {