Skip to content

Commit 4fdfaa5

Browse files
committed
update py
1 parent 1222959 commit 4fdfaa5

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

py/pycompiler.vim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,16 @@ function s:PythonCompiler.compile_execute(node)
485485
endfunction
486486

487487
function s:PythonCompiler.compile_ternary(node)
488-
return printf('%s if %s else %s', self.compile(a:node.left), self.compile(a:node.cond), self.compile(a:node.right))
488+
let cond = self.compile(a:node.cond)
489+
if s:opprec[a:node.type] >= s:opprec[a:node.cond.type]
490+
let cond = '(' . cond . ')'
491+
endif
492+
let left = self.compile(a:node.left)
493+
if s:opprec[a:node.type] >= s:opprec[a:node.left.type]
494+
let left = '(' . left . ')'
495+
endif
496+
let right = self.compile(a:node.right)
497+
return printf('%s if %s else %s', left, cond, right)
489498
endfunction
490499

491500
function s:PythonCompiler.compile_or(node)

py/vimlparser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ def parse_cmd_return(self):
12311231
node.left = NIL
12321232
self.reader.skip_white()
12331233
c = self.reader.peek()
1234-
if not self.ends_excmds(c):
1234+
if c == "\"" or not self.ends_excmds(c):
12351235
node.left = self.parse_expr()
12361236
self.add_node(node)
12371237

0 commit comments

Comments
 (0)