Skip to content

Commit 8b54071

Browse files
authored
Merge pull request python-mode#1055 from python-mode/improve-user-raw-input
Improve user_input's input/raw_input compatibility.
2 parents 1ce5ce3 + b8c9acf commit 8b54071

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

pymode/environment.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,31 @@ def message(msg, history=False):
8484

8585
return vim.command('call pymode#wide_message("%s")' % str(msg))
8686

87-
def user_input(self, msg, default=''):
87+
def user_input(self, msg='', default=''):
8888
"""Return user input or default.
8989
9090
:return str:
9191
9292
"""
93-
msg = '%s %s ' % (self.prefix, msg)
93+
prompt = []
94+
prompt.append(str(self.prefix.strip()))
95+
prompt.append(str(msg).strip())
9496

9597
if default != '':
96-
msg += '[%s] ' % default
98+
prompt.append('[%s]' % default)
99+
100+
prompt.append('> ')
101+
prompt = ' '.join([s for s in prompt if s])
102+
103+
vim.command('echohl Debug')
97104

98105
try:
99-
vim.command('echohl Debug')
100-
input_str = vim.eval('input("%s> ")' % msg)
101-
vim.command('echohl none')
106+
input_str = vim.eval('input(%r)' % (prompt,))
102107
except KeyboardInterrupt:
103108
input_str = ''
104109

110+
vim.command('echohl none')
111+
105112
return input_str or default
106113

107114
def user_confirm(self, msg, yes=False):

0 commit comments

Comments
 (0)