Skip to content

Commit 77f99b3

Browse files
committed
update js
1 parent 4fdfaa5 commit 77f99b3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

js/jscompiler.vim

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,13 @@ function s:JavascriptCompiler.compile_execute(node)
533533
endfunction
534534

535535
function s:JavascriptCompiler.compile_ternary(node)
536-
return printf('%s ? %s : %s', self.compile(a:node.cond), self.compile(a:node.left), self.compile(a:node.right))
536+
let cond = self.compile(a:node.cond)
537+
if s:opprec[a:node.type] >= s:opprec[a:node.cond.type]
538+
let cond = '(' . cond . ')'
539+
endif
540+
let left = self.compile(a:node.left)
541+
let right = self.compile(a:node.right)
542+
return printf('%s ? %s : %s', cond, left, right)
537543
endfunction
538544

539545
function s:JavascriptCompiler.compile_or(node)

js/vimlparser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,7 @@ VimLParser.prototype.parse_cmd_return = function() {
15221522
node.left = NIL;
15231523
this.reader.skip_white();
15241524
var c = this.reader.peek();
1525-
if (!this.ends_excmds(c)) {
1525+
if (c == "\"" || !this.ends_excmds(c)) {
15261526
node.left = this.parse_expr();
15271527
}
15281528
this.add_node(node);

0 commit comments

Comments
 (0)