jarod2d / sublime_valign

Vertical alignment plugin for Sublime Text 2 and 3
91 stars 7 forks source link

Incorrect alignment in JavaScript with the var-statement #22

Open sascha-wolf opened 10 years ago

sascha-wolf commented 10 years ago

This problem occurs when the other lines aren't "long" enough to be considered as the longest line. Since the line with the var-statement has 4 extra characters ("var ") it can happen that the plugin consideres this line the longest and the indentation gets wrong.

To make clear what I mean a little example where this happens.

Before

var routes = require('./routes'),
    express = require('express'),
    mailer = require('nodemailer'),
    fs = require('fs'),
    _ = require('underscore'),

After

var routes = require('./routes'),
    express   = require('express'),
    mailer    = require('nodemailer'),
    fs        = require('fs'),
    _         = require('underscore'),

Any idea how to fix that?

jarod2d commented 10 years ago

Hmm, good find. This should be an issue that happens exclusively in this situation, with the var prefix on the first line. I took a look, and it doesn't seem like a quick fix, unfortunately. The way the app handles the "var " prefix on a line is a bit hacky, and it probably needs to be refactored for this to work properly. I don't have any more time to investigate at the moment, but the next time I do I'll see what I can do about it.

kbuchanan commented 10 years ago

I would also love to see this, if there's ever more work on it.