--- a/UI/FindFileDialog.py Tue Jan 18 16:31:26 2011 +0100 +++ b/UI/FindFileDialog.py Tue Jan 18 19:32:48 2011 +0100 @@ -269,6 +269,15 @@ elif button == self.stopButton: self.__stopSearch() + def __stripEol(self, txt): + """ + Private method to strip the eol part. + + @param txt line of text that should be treated (string) + @return text with eol stripped (string) + """ + return txt.replace("\r", "").replace("\n", "") + def __stopSearch(self): """ Private slot to handle the stop button being pressed. @@ -420,7 +429,7 @@ # read the file and split it into textlines try: text, encoding, hash = Utilities.readEncodedFileWithHash(fn) - lines = text.splitlines() + lines = text.splitlines(True) except (UnicodeError, IOError): progress += 1 self.findProgress.setValue(progress) @@ -441,12 +450,14 @@ rline = search.sub(replTxt, line) else: rline = "" + line = self.__stripEol(line) if len(line) > 1024: line = "{0} ...".format(line[:1024]) if self.__replaceMode: if len(rline) > 1024: rline = "{0} ...".format(line[:1024]) - line = "- {0}\n+ {1}".format(line, rline) + line = "- {0}\n+ {1}".format( + line, self.__stripEol(rline)) self.__createItem(file, count, line, start, end, rline, hash) @@ -581,7 +592,7 @@ try: text, encoding, hash = \ Utilities.readEncodedFileWithHash(fn) - lines = text.splitlines() + lines = text.splitlines(True) except (UnicodeError, IOError): E5MessageBox.critical(self, self.trUtf8("Replace in Files"), @@ -618,11 +629,7 @@ lines[line - 1] = rline # write the file - if self.project.isProjectFile(fn): - eol = self.project.getEolString() - else: - eol = Utilities.linesep() - txt = eol.join(lines) + Utilities.linesep() + txt = "".join(lines) try: Utilities.writeEncodedFile(fn, txt, encoding) except (IOError, Utilities.CodingError, UnicodeError) as err: