Skip to content
Permalink
Browse files

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.
  • Loading branch information...
dvbridges authored and peircej committed Feb 19, 2019
1 parent f93628d commit 94c5ee6a2b4f9b97ebd45435e66709c1d6b4c169
Showing with 5 additions and 3 deletions.
  1. +5 −3 psychopy/app/coder/codeEditorBase.py
@@ -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
@@ -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.
You can’t perform that action at this time.