Skip to content

Commit 94c5ee6

Browse files
dvbridgespeircej
authored andcommitted
BF: Make EOL replacement without wx and handle exceptions
The call to convertEOL added an extra step in the paste process, leaving extra steps to undo in the event of using undo after paste. This fix looks for non-unix EOLs and replaces them with unix EOLs using string replace method.
1 parent f93628d commit 94c5ee6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

psychopy/app/coder/codeEditorBase.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import sys
1515
from pkg_resources import parse_version
1616
from psychopy.constants import PY3
17+
from psychopy import logging
18+
1719

1820
class BaseCodeEditor(wx.stc.StyledTextCtrl):
1921
"""Provides base class for code editors
@@ -235,8 +237,8 @@ def Paste(self, event=None):
235237
try:
236238
# if we can decode from utf-8 then all is good
237239
txt.decode('utf-8')
238-
except:
240+
except Exception as e:
241+
logging.error(str(e))
239242
# if not then wx conversion broke so get raw data instead
240243
txt = dataObj.GetDataHere()
241-
self.ReplaceSelection(txt)
242-
self.ConvertEOLs(wx.stc.STC_EOL_LF)
244+
self.ReplaceSelection(txt.replace("\r\n", "\n").replace("\r", "\n"))

0 commit comments

Comments
 (0)