# HG changeset patch # User Chris Cannam # Date 1341311943 -3600 # Node ID 372b191247da54ab2aae3ddb63f704be5fe8a72f # Parent ab92f695f776ce3a98b4fda94e5897efc9dd17ab Add carriage return to hgignore file before new material, if it didn't end with one before diff -r ab92f695f776 -r 372b191247da src/mainwindow.cpp --- a/src/mainwindow.cpp Tue Jul 03 11:22:10 2012 +0100 +++ b/src/mainwindow.cpp Tue Jul 03 11:39:03 2012 +0100 @@ -766,9 +766,12 @@ f.open(QFile::ReadOnly); bool glob = false; + bool cr = false; // whether the last line examined ended with a CR while (!f.atEnd()) { QByteArray ba = f.readLine(); - QString s = QString::fromLocal8Bit(ba).trimmed(); + QString s = QString::fromLocal8Bit(ba); + cr = (s.endsWith('\n') || s.endsWith('\r')); + s = s.trimmed(); if (s.startsWith("syntax:")) { if (s.endsWith("glob")) { glob = true; @@ -782,6 +785,10 @@ f.open(QFile::Append); QTextStream out(&f); + if (!cr) { + out << endl; + } + if (!glob) { out << "syntax: glob" << endl; }