Skip to content

Commit

Permalink
BF: Make EOL replacement without wx and handle exceptions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dvbridges authored and peircej committed Feb 19, 2019
1 parent f93628d commit 94c5ee6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions psychopy/app/coder/codeEditorBase.py
Expand Up @@ -14,6 +14,8 @@
import sys
from pkg_resources import parse_version
from psychopy.constants import PY3
from psychopy import logging


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

0 comments on commit 94c5ee6

Please sign in to comment.