Browse Source

Improved fix for #51. Now only replaces stand-alone carriage returns with newlines.

merge-requests/365/head
eidheim 10 years ago
parent
commit
a3d950b6bc
  1. 16
      src/source.cc

16
src/source.cc

@ -405,24 +405,16 @@ void Source::View::replace_all(const std::string &replacement) {
void Source::View::paste() { void Source::View::paste() {
auto text=Gtk::Clipboard::get()->wait_for_text(); auto text=Gtk::Clipboard::get()->wait_for_text();
//remove carriage returns (which makes clang return wrong line index) //replace stand-alone carriage returns (which makes clang return wrong line index) with newlines
for(auto it=text.begin();it!=text.end();) { for(auto it=text.begin();it!=text.end();it++) {
if(*it=='\r') { if(*it=='\r') {
auto it2=it; auto it2=it;
it2++; it2++;
if(it2!=text.end()) { if(it2!=text.end() && *it2!='\n')
if(*it2=='\n')
it=text.erase(it);
else {
text.replace(it, it2, "\n"); text.replace(it, it2, "\n");
it++;
}
}
else else
it=text.erase(it); text.replace(it, it2, "\n");
} }
else
it++;
} }
auto line=get_line_before(); auto line=get_line_before();

Loading…
Cancel
Save