| 180 | } |
| 181 | |
| 182 | void History::updateFileContents(const QString& file, const QString& contents) |
| 183 | { |
| 184 | auto it = _history.find(file); |
| 185 | if (it == _history.end()) { |
| 186 | return; |
| 187 | } |
| 188 | FileDiff d(it.value().snapshot, contents); |
| 189 | auto diff = d.diff(); |
| 190 | if (diff.empty()) { |
| 191 | return; |
| 192 | } |
| 193 | History::Change c; |
| 194 | c.edits = diff; |
| 195 | c.timestamp = static_cast<double>(QDateTime::currentMSecsSinceEpoch()) / 1000.0; |
| 196 | it.value().changes.append(std::move(c)); |
| 197 | it.value().snapshot = contents; |
| 198 | emit historyChanged(); |
| 199 | } |
| 200 | |
| 201 | void History::commit() { |
| 202 | for (auto it = _history.begin(); it != _history.end(); it++) { |