From 875640c5c171bb7b43d2824b27782671a5177891 Mon Sep 17 00:00:00 2001 From: chrys Date: Fri, 2 Sep 2016 23:16:11 +0200 Subject: [PATCH] redu wrong fix --- src/fenrir-package/screen/linux.py | 37 +++++++++++++++++------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 32cb9fa9..2eb38dd9 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -65,26 +65,31 @@ class screen(): environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldDelta'] = '' environment['screenData']['oldNegativeDelta'] = '' - # always clear deltas + # always clear current deltas environment['screenData']['newNegativeDelta'] = '' - environment['screenData']['newDelta'] = '' + environment['screenData']['newDelta'] = '' # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ (environment['screenData']['newContentText'] != '' ): - diffStart = 0 - if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ - environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ - environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: - diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] - diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ - environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) + if environment['screenData']['oldContentText'] == '' and\ + environment['screenData']['newContentText'] != '': + environment['screenData']['newDelta'] = environment['screenData']['newContentText'] else: - diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ - environment['screenData']['newContentText'][diffStart:].split('\n')) - - diffList = list(diff) + diffStart = 0 + if environment['screenData']['oldCursor']['x'] != environment['screenData']['newCursor']['x'] and \ + environment['screenData']['oldCursor']['y'] == environment['screenData']['newCursor']['y'] and \ + environment['screenData']['newContentText'][:environment['screenData']['newCursor']['y']] == environment['screenData']['oldContentText'][:environment['screenData']['newCursor']['y']]: + diffStart = environment['screenData']['newCursor']['y'] * environment['screenData']['columns'] + environment['screenData']['newCursor']['y'] + diff = difflib.ndiff(environment['screenData']['oldContentText'][diffStart:diffStart + environment['screenData']['columns']],\ + environment['screenData']['newContentText'][diffStart:diffStart + environment['screenData']['columns']]) + else: + diff = difflib.ndiff( environment['screenData']['oldContentText'][diffStart:].split('\n'),\ + environment['screenData']['newContentText'][diffStart:].split('\n')) + + diffList = list(diff) + + environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) + environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) - environment['screenData']['newDelta'] = ''.join(x[2:] for x in diffList if x.startswith('+ ')) - environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diffList if x.startswith('- ')) - return environment +