Changeset View
Changeset View
Standalone View
Standalone View
src/document/katedocument.cpp
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | |||||
45 | #include "spellcheck/ontheflycheck.h" | 45 | #include "spellcheck/ontheflycheck.h" | ||
46 | #include "spellcheck/spellcheck.h" | 46 | #include "spellcheck/spellcheck.h" | ||
47 | #include "katescriptmanager.h" | 47 | #include "katescriptmanager.h" | ||
48 | #include "kateswapfile.h" | 48 | #include "kateswapfile.h" | ||
49 | #include "katepartdebug.h" | 49 | #include "katepartdebug.h" | ||
50 | #include "printing/kateprinter.h" | 50 | #include "printing/kateprinter.h" | ||
51 | #include "kateabstractinputmode.h" | 51 | #include "kateabstractinputmode.h" | ||
52 | #include "katetemplatehandler.h" | 52 | #include "katetemplatehandler.h" | ||
53 | #include "katevariableexpansionmanager.h" | ||||
53 | 54 | | |||
54 | #if EDITORCONFIG_FOUND | 55 | #if EDITORCONFIG_FOUND | ||
55 | #include "editorconfig.h" | 56 | #include "editorconfig.h" | ||
56 | #endif | 57 | #endif | ||
57 | 58 | | |||
58 | #include <KTextEditor/DocumentCursor> | 59 | #include <KTextEditor/DocumentCursor> | ||
59 | #include <KTextEditor/Attribute> | 60 | #include <KTextEditor/Attribute> | ||
60 | 61 | | |||
▲ Show 20 Lines • Show All 2522 Lines • ▼ Show 20 Line(s) | 2550 | { | |||
2583 | */ | 2584 | */ | ||
2584 | if (!needBackup) { | 2585 | if (!needBackup) { | ||
2585 | return true; | 2586 | return true; | ||
2586 | } | 2587 | } | ||
2587 | 2588 | | |||
2588 | /** | 2589 | /** | ||
2589 | * else: try to backup | 2590 | * else: try to backup | ||
2590 | */ | 2591 | */ | ||
2591 | if (config()->backupPrefix().contains(QDir::separator())) { | 2592 | const auto backupPrefix = KTextEditor::EditorPrivate::self()->variableExpansionManager()->expandText(config()->backupPrefix(), nullptr); | ||
2593 | const auto backupSuffix = KTextEditor::EditorPrivate::self()->variableExpansionManager()->expandText(config()->backupSuffix(), nullptr); | ||||
2594 | if (backupPrefix.isEmpty() && backupSuffix.isEmpty()) { | ||||
dhaumann: Shall we wrap all this with
if (!(backupSuffix.isEmpty() && backupPrefix.isEmpty())) {...} | |||||
cullmann: Why not, saves useless evals. | |||||
No: that's exactly the point: I currently don't think it's possible, but both evals could result in empty strings. Can you do the integration? Author does not matter. dhaumann: No: that's exactly the point: I currently don't think it's possible, but both evals could… | |||||
2595 | // no sane backup possible | ||||
2596 | return true; | ||||
2597 | } | ||||
2598 | | ||||
2599 | if (backupPrefix.contains(QDir::separator())) { | ||||
2592 | /** | 2600 | /** | ||
2593 | * replace complete path, as prefix is a path! | 2601 | * replace complete path, as prefix is a path! | ||
2594 | */ | 2602 | */ | ||
2595 | u.setPath(config()->backupPrefix() + u.fileName() + config()->backupSuffix()); | 2603 | u.setPath(backupPrefix + u.fileName() + backupSuffix); | ||
2596 | } else { | 2604 | } else { | ||
2597 | /** | 2605 | /** | ||
2598 | * replace filename in url | 2606 | * replace filename in url | ||
2599 | */ | 2607 | */ | ||
2600 | const QString fileName = u.fileName(); | 2608 | const QString fileName = u.fileName(); | ||
2601 | u = u.adjusted(QUrl::RemoveFilename); | 2609 | u = u.adjusted(QUrl::RemoveFilename); | ||
2602 | u.setPath(u.path() + config()->backupPrefix() + fileName + config()->backupSuffix()); | 2610 | u.setPath(u.path() + backupPrefix + fileName + backupSuffix); | ||
2603 | } | 2611 | } | ||
2604 | 2612 | | |||
2605 | qCDebug(LOG_KTE) << "backup src file name: " << url(); | 2613 | qCDebug(LOG_KTE) << "backup src file name: " << url(); | ||
2606 | qCDebug(LOG_KTE) << "backup dst file name: " << u; | 2614 | qCDebug(LOG_KTE) << "backup dst file name: " << u; | ||
2607 | 2615 | | |||
2608 | // handle the backup... | 2616 | // handle the backup... | ||
2609 | bool backupSuccess = false; | 2617 | bool backupSuccess = false; | ||
2610 | 2618 | | |||
▲ Show 20 Lines • Show All 3478 Lines • Show Last 20 Lines |
Shall we wrap all this with