Skip to content

Commit

Permalink
cmds: force utf-8 when displaying untracked files
Browse files Browse the repository at this point in the history
We do a partial read of untracked files which means that we may
sometimes read invalid utf-8 when the read is truncated.

Handle this in a more robust way by forcing utf-8 and skipping over
truncated bytes at the end of the read.

Closes #401
Reported-by: V字龍(Vdragon) <Vdragon.Taiwan@gmail.com>
Signed-off-by: David Aguilar <davvid@gmail.com>
  • Loading branch information
davvid committed Dec 29, 2014
1 parent 83bd876 commit eedad43
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cola/cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,8 @@ def diff_text_for(self, filename):
cfg = gitcfg.current()
size = cfg.get('cola.readsize', 1024 * 2)
try:
result = core.read(filename, size=size)
result = core.read(filename, size=size,
encoding='utf-8', errors='ignore')
except:
result = ''

Expand Down

0 comments on commit eedad43

Please sign in to comment.