simple-javascript-indenter icon indicating copy to clipboard operation
simple-javascript-indenter copied to clipboard

break })

Open guileen opened this issue 13 years ago • 3 comments

e.g.

foo({
}|)

type ,{}<left><cr>

foo({
},{
});

but should be

foo({
  },{
});

guileen avatar Nov 12 '11 16:11 guileen

I've made it indent as more as possible in 1.4.3, so it should be a feature for me just add a global option g:SimpleJsIndenter_GreedyIndent set it to 0 to make }, { does't indent.

The line starts with '} else' will still be indented. related condition in source: s:IsOneLineIndentLoose(pline)

if () {
} else {
}

The line doesn't contains any isolated [({ will still be indented as more as possible. related condition in source: pline !~ s:expr_left

foo({
}, b());

jiangmiao avatar Nov 12 '11 20:11 jiangmiao

I have try it, but I think it's not the problem of indent rule, the old rule is right, the problem happens at <cr> pressed, if I type == at the line of },{, it will be what it should be.

guileen avatar Nov 14 '11 06:11 guileen

sorry, just understood, you are using Normal Mode instead of Brief Mode and the previous line won't reindent after entering <CR>, I have no idea how to solve the issue by adding rule to indentkeys. Here is another solution is imap the <CR>

inoremap <CR> <CR>.<ESC>k==jI<DEL>

or try my another plugin auto-pairs which already map the <CR> but there is an annoy thing currently, the cursor will flash at previous line when press <CR>.

jiangmiao avatar Nov 14 '11 09:11 jiangmiao