8000 Fix encoding bug · python-mode/python-mode@ce87975 · GitHub
[go: up one dir, main page]

Skip to content

Commit ce87975

Browse files
committed
Fix encoding bug
1 parent ad7a3b3 commit ce87975

File tree

5 files changed

+20
-6
lines changed

5 files changed

+20
-6
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Contributors:
2323
* Lowe Thiderman (thiderman);
2424
* Martin Brochhaus (mbrochh);
2525
* Matthew Moses (mlmoses);
26+
* Mel Boyce (syngin)
2627
* Mohammed (mbadran);
2728
* Naoya Inada (naoina);
2829
* Pedro Algarvio (s0undt3ch);

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ clean:
1111
# Temporary disable rope tests on Travis
1212
.PHONY: travis
1313
travis:
14-
rm -rf t/rope.vim
1514
rake test
1615

1716
.PHONY: test

pymode/environment.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ def var(self, name, to_bool=False):
7777
return value
7878

7979
def message(self, msg, history=False):
80-
""" Show message to user. """
80+
""" Show message to user.
81+
82+
:return: :None
83+
84+
"""
8185

8286
if history:
8387
return vim.command('echom "%s"' % str(msg))
@@ -188,14 +192,16 @@ def let(self, name, value):
188192
self.debug(cmd)
189193
vim.command(cmd)
190194

191-
def prepare_value(self, value):
195+
def prepare_value(self, value, dumps=True):
192196
""" Decode bstr to vim encoding.
193197
194198
:return unicode string:
195199
196 8000 200
"""
197201

198-
value = json.dumps(value)
202+
if dumps:
203+
value = json.dumps(value)
204+
199205
if PY2:
200206
value = value.decode('utf-8').encode(self.options.get('encoding'))
201207

pymode/rope.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ def complete(dot=False):
8585
s_offset = codeassist.starting_offset(source, offset)
8686
p_prefix = prefix[offset - s_offset:]
8787
line = env.lines[row - 1]
88-
env.curbuf[row - 1] = line[:col] + p_prefix + line[col:] # noqa
88+
cline = line[:col] + p_prefix + line[col:]
89+
if cline != line:
90+
env.curbuf[row - 1] = env.prepare_value(cline, dumps=False)
8991
env.current.window.cursor = (row, col + len(p_prefix))
9092
env.run('complete', col - len(prefix) + len(p_prefix) + 1, proposals)
9193
return True
@@ -887,7 +889,8 @@ def _insert_import(name, module, ctx):
887889
source, _ = env.get_offset_params()
888890
lineno = ctx.importer.find_insertion_line(source)
889891
line = 'from %s import %s' % (module, name)
890-
env.curbuf[lineno - 1:lineno - 1] = [line]
892+
env.curbuf[lineno - 1:lineno - 1] = [
893+
env.prepare_value(line, dumps=False)]
891894
return True
892895

893896
pyobject = ctx.project.pycore.resource_to_pyobject(ctx.resource)

t/rope.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ describe 'pymode-plugin'
1717
end
1818

1919
it 'pymode rope auto open project in current working directory'
20+
21+
if $TRAVIS != ""
22+
SKIP 'Travis fails on this test'
23+
endif
24+
2025
let project_path = getcwd() . '/.ropeproject'
2126
Expect isdirectory(project_path) == 0
2227
normal oimporX

0 commit comments

Comments
 (0)
0