Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as vscode from "vscode";
enum TokenType {
Invalid
, Word
, Assignment // = += -= *= /=
, Assignment // = += -= *= /= ?= := <=
, Arrow // =>
, Block // {} [] ()
, PartialBlock // { [ (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 != "=" ) {
Expand Down