Skip to content

Commit 1eabf5b

Browse files
committed
io/fileview: ensure directory is watched for file creation
1 parent aeb347b commit 1eabf5b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/io/fileview.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,14 @@ void FileView::updateWatchedFiles() {
490490
qCDebug(logFileView) << "Creating watcher for" << this << "at" << this->targetPath;
491491
this->watcher = new QFileSystemWatcher(this);
492492
this->watcher->addPath(this->targetPath);
493-
this->watcher->addPath(QDir(this->targetPath).dirName());
493+
494+
auto dirPath = this->targetPath;
495+
if (!dirPath.contains("/")) dirPath = "./" % dirPath;
496+
497+
if (auto lastIndex = dirPath.lastIndexOf('/'); lastIndex != -1) {
498+
dirPath = dirPath.sliced(0, lastIndex);
499+
this->watcher->addPath(dirPath);
500+
}
494501

495502
QObject::connect(
496503
this->watcher,

0 commit comments

Comments
 (0)