-
Notifications
You must be signed in to change notification settings - Fork 352
random fixes and improvements #435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
this also removes the parentheses alignment, we can leave it in I suppose, but I'd like to revisit that later. if anyone objects please let me know.this needs to be cleaned up a bit before merging
Can you elaborate a bit on the parenthesis alignment stuff and what t means if it's removed? |
it is the same as #75 . Basically with my changes the indenting will only move the the following line a sw's space |
what I would like to try eventually is only making alignment happen when using a comma/operator first style, like https://docs.npmjs.com/misc/coding-style . |
@@ -41,7 +41,7 @@ endif | |||
" 1. Variables {{{1 | |||
" ============ | |||
|
|||
let s:js_keywords = '^\s*\%(break\|catch\|const\|continue\|debugger\|delete\|do\|else\|finally\|for\|function\|if\|in\|instanceof\|let\|new\|return\|switch\|this\|throw\|try\|typeof\|var\|void\|while\|with\)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by the way, here is the file filled with some heinous code examples that I test with, and the results
(function(window) {
(function() {
console.log("value");
var magicWords = ['abracadabra', 'gesundheit', 'ventrilo'],
spells = {
'fireball': function() {
setOnFire()
},
'water': function() {
putOut()
}
},
a = 1,
b = 'abc',
etc;
someFunc(param1, param2,
param3, param4)
}());
randomFunctionCall('blaaaaaaaaaaaaaa ', 'and some more bla',
f)
var i = 5,
t = 2;
var i = 0,
t = 9
console.log("value");
function addMethods(source) {
var ancestor = this.superclass && this.superclass.prototype,
properties = Object.keys(source);
if (IS_DONTENUM_BUGGY) {
if (source.toString != Object.prototype.toString)
properties.push("toString");
if (source.valueOf != Object.prototype.valueOf)
properties.push("valueOf");
}
for (var i = 0, length = properties.length; i < length; i++) {
var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames()[0] == "$super") {
var method = value;
value = (function(m) {
return function() { return ancestor[m].apply(this, arguments); };
})(property).wrap(method);
value.valueOf = (function(method) {
return function() { return method.valueOf.call(method); };
})(method);
value.toString = (function(method) {
return function() { return method.toString.call(method); };
})(method);
}
this.prototype[property] = value;
}
return this;
}
if (!options.evalJSON || (options.evalJSON != 'force' &&
!(this.getHeader('Content-type') || '').include('application/json')) ||
this.responseText.blank())
return null;
function getPixelValue(value, property, context) {
if (element && isPercentage) {
context = context || element.parentNode;
var decimal = toDecimal(value),
whole = null;
var isHorizontal = property.include('left') || property.include('right') ||
property.include('width');
var isVertical = property.include('top') || property.include('bottom') ||
ilude('ght');
return (whole === null) ? 0 : whole * decimal;
}
var i = 9
, k = 9
function hasAttribute_IE(element, attribute) {
GLOBAL.Element.Methods.Simulated.hasAttribute =
PROBLEMATIC_HAS_ATTRIBUTE_WITH_CHECKBOXES ?
hasAttribute_IE : hasAttribute;
function classNames(element) {
return new Element.ClassNames(element);
}
}
GLOBAL.Element.Methods.Simulated.hasAttribute =
PROBLEMATIC_HAS_ATTRIBUTE_WITH_CHECKBOXES ?
hasAttribute_IE : hasAttribute;
function classNames(element) {
return new Element.ClassNames(element);
}
var regExpCache = {};
function getRegExpForClassName(className) {
var nop = function() {};
var __method = this,
args = slice.call(arguments, 1);
console.log("value");
}
(function(window) {
expando = "sizzle" + -(new Date()),
preferredDoc = window.document,
dirruns = 0,
done = 0,
classCache = createCache(),
tokenCache = createCache(),
compilerCache = createCache(),
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
}
return 0;
}
}(window));
one()
.then(two)
.then(function() {
console.log("value");
})
foo(a(b,
c))
protocol = self.proxy && !self.tunnel ? self.proxy.protocol : self.uri.protocol,
defaultModules = {
'http:': http,
'https:': https
},
htpModles = slf.htpModules || {}
elf.httpModule = htpModules[protocol] || efaultModules[protocol]
if( a == b
&& c == d
&& e == f
|| g == h
|| i == j ) {
a = b
+ c
- d; }
temp, i, elem,
preMap = [],
postMap = [],
preexisting = results.length,
elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
matcherIn = preFilter && ( seed || !selector ) ?
condense( elems, preMap, preFilter, context, xml ) :
elems,
matcherOut = matcher ?
postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
[] :
results :
matcherIn;
}
// comma-first
var o =
{ a : "ape"
, b : "bat"
, c : "cat"
, d : "dog"
, f : "fly"
, g : "gnu"
, h : "hat"
, i : "ibu"
}
, a =
[ [ "ape", "bat" ]
, [ "cat", "dog" ]
, [ "elf", "fly" ]
, [ "ibu" ]
];
// Addendum: effects on the return statement.
// It does not break.
return [ 1
, 2
, 3
] // returns [1,2,3]
return { a : "ape"
, b : "bat"
} // returns {a:"ape",b:"bat"}
// even just separating two values by commas is fine,
// though a bit silly
return 1
, 2
, 3
, 4 // returns the last value, 4
// this, however is wrong:
return
1
, 2 // returns undefined, because of semicolon-insertion.
// so is this. otb == fail.
return
{ a : "ape"
, b : "bat"
} // returns undefined,
// then creates a block with two named statements.
// this is ok:
return ( 1
, 2
) // returns 2
// so is this:
return (
{ a : "ape"
, b : "bat"
}
) // returns {a:"ape",b:"bat"}
// Addendum 2: A function call
doSomething( aPrettyLongVariableName
, "A string, which has some useful information"
, "If you put these all together, it'd be too long"
, { a: "is for antelope", b: "is for bat" }
, 42
)
// Addendum 3: More realistic error in standard style:
// leaks FIVE globals!
var a = "ape eat banana",
b = "bat, allowed to fly",
c = "cat toy",
e = "elf lord",
f = "fly through the air",
g = "gnu is not unix",
h = "hat goes on your head",
i = "ibu isn't a cow";
// Error: Can't call method 'forEach' of undefined.
// not passing in undefined as an argument!??
mergeLists([ apple, [ penelope, granger ] ],
[ fun ],
[ 1, 2, 3, 4, 5, 6, 7, 8 ]
[ "mary's store has many pies, and cookies, and eggs," ]
[ function() { doSomething() } ]);
}(window));
this is ready, what do you say @amadeus ? |
Yeah, I am good with trying this out in Perhaps squash the commits and it'd be good to go. |
this also removes the parentheses alignment, we can leave it in I suppose, but I'd like to revisit that later. if anyone objects please let me know.this needs to be cleaned up a bit before merging