adrianlee44 / atom-aligner

Easily align multi-line with support for different operators and custom configurations
https://atom.io/packages/aligner
MIT License
77 stars 3 forks source link

Aligning doesn't work in JS object literals that contain functions #19

Closed markwainwright closed 9 years ago

markwainwright commented 9 years ago

Thanks for all your hard work on this package. It's awesome.

One bug: placing the cursor on the second line of

var a = {
  b: 'b',
  c: function(){}
};

and activating the plugin gives:

var a = {
  b : 'b',
  c: function(){} undefined 
};
adrianlee44 commented 9 years ago

Thanks for reporting the issue. There seems to be 2 bugs here.

  1. appending undefined Do you have Show Invisibles option enabled? Also, do you have any other aligner plugin activated?
  2. not aligning at all This seems to be an upstream bug with language-javascript not tokenizing c: function(){} correctly.
markwainwright commented 9 years ago

Hey - thanks for the reply.

No, I don't have Show Invisibles enabled. I just disabled all other community plugins and was able to still reproduce the issue.

adrianlee44 commented 9 years ago

Got it. I'll continue to look into the undefined bug. As for the alignment issue, it should be resolved with the next Atom release since a fix has been merged on language-javascript (atom/language-javascript#153)

adrianlee44 commented 9 years ago

Completely forgot about this bug, @markwainwright, is this still an issue?

gwilakers commented 9 years ago

Yes, @adrianlee44 , I can confirm this is still a bug. I am seeing it happen in my code when trying to align things like node require packages and such.

gwilakers commented 9 years ago

@adrianlee44 Looked into this any?

adrianlee44 commented 9 years ago

@gwilakers, yea. Was just looking into this yesterday. I wasn't able to reproduce this but I have idea where this is happening.

Also, which OS are you on and any chance there is trailing whitespace when you align?

gwilakers commented 9 years ago

Okay cool. I am on a Mac, and I made sure to remove the trailing whitespace before using the package. Here is a simple example of a piece of code that will not align properly:

var database_config = require('some.config.file').database,
    r = require('rethinkdb');
adrianlee44 commented 9 years ago

@gwilakers, you should not need to remove trailing whitespace before using the package. As for not aligning properly, is the problem you are seeing the same as #12?

gwilakers commented 9 years ago

@adrianlee44 I do not believe so, as I have tried the fix suggested at the bottom of that thread and still receive the same results. Here is another example of code that will not align:

var geocoderProvider  = ['google', 'opencage'];
var httpAdapter = 'https';
adrianlee44 commented 9 years ago

@gwilakers, the case at the bottom of that thread and also being able to align var code, such as the one below, is not implemented yet.

var testing = ['hello', 'world'],
      test = '123';

As for the case you mentioned above, it aligns correctly for me. Maybe I ask what version of Atom and aligner are you on?

gwilakers commented 9 years ago

I am using Atom 1.0.5, which the case you mention working for you does not work for me in. Another example that does not work is:

var express = require('express');
var router = express.Router();
adrianlee44 commented 9 years ago

@gwilakers, I would need some help and more debug information to figure out this problem.

Packages

Can you paste the output of apm ls --installed? It should be something like this

/home/adrian/.atom/packages (17)
├── aligner@0.15.0
├── aligner-css@1.2.0
├── aligner-php@1.0.0
├── aligner-ruby@1.4.0
├── base16-ocean-dark-spacegray@0.10.0
├── coffee-compile@0.18.0
├── file-icons@1.6.3
├── git-blame@0.4.5
├── linter@1.3.4
├── linter-jshint@1.1.5
├── minimap@4.12.2
├── sort-lines@0.11.0
├── spacegray-atom-dark-ui@1.0.0
├── spacegray-dark-ui@0.12.0
└── starcraft-tips@0.2.0

Keybinding

Atom has a keybinding resolver and can be activate with cmd-.. Can you screen capture the output when pressing either ctrl-cmd-/ or ctrl-alt-/ based on your platform?

Console output

Open up the developer tool and see if there are any output / errors when you try to align text.

Thanks in advance. :)

adrianlee44 commented 9 years ago

The original bug described in this issue should be fixed. Please reopen this issue if undefined is still being appended.