From cf13a5aa5d9d38303f11c3bd09eb7a70a617d104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Tue, 25 Jul 2023 00:42:10 -0300 Subject: [PATCH] ecode: Improved file system listener. --- src/thirdparty/efsw | 2 +- src/tools/ecode/filesystemlistener.cpp | 7 +++++++ src/tools/ecode/projectdirectorytree.cpp | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/thirdparty/efsw b/src/thirdparty/efsw index ac1a2fc2c..a2a0e475c 160000 --- a/src/thirdparty/efsw +++ b/src/thirdparty/efsw @@ -1 +1 @@ -Subproject commit ac1a2fc2cb7d41d3aa9f655347e48df97e2489bd +Subproject commit a2a0e475ca283321a7af38ec042893ab55e1b053 diff --git a/src/tools/ecode/filesystemlistener.cpp b/src/tools/ecode/filesystemlistener.cpp index d5a26e7c4..186e7208a 100644 --- a/src/tools/ecode/filesystemlistener.cpp +++ b/src/tools/ecode/filesystemlistener.cpp @@ -70,12 +70,19 @@ void FileSystemListener::handleFileAction( efsw::WatchID, const std::string& dir } } + if ( file.isLink() ) + file = FileInfo( file.linksTo() ); + + if ( isFileOpen( file ) ) + notifyChange( file ); + Lock l( mCbsMutex ); if ( !mCbs.empty() ) { auto cbs = mCbs; for ( const auto& cb : cbs ) cb.second( event, file ); } + break; } case efsw::Actions::Modified: { diff --git a/src/tools/ecode/projectdirectorytree.cpp b/src/tools/ecode/projectdirectorytree.cpp index 8d362527e..92125625d 100644 --- a/src/tools/ecode/projectdirectorytree.cpp +++ b/src/tools/ecode/projectdirectorytree.cpp @@ -324,8 +324,11 @@ void ProjectDirectoryTree::tryAddFile( const FileInfo& file ) { } if ( foundPattern ) { Lock l( mFilesMutex ); - mFiles.emplace_back( file.getFilepath() ); - mNames.emplace_back( file.getFileName() ); + auto exists = std::find( mFiles.begin(), mFiles.end(), file.getFilepath() ) != mFiles.end(); + if ( !exists ) { + mFiles.emplace_back( file.getFilepath() ); + mNames.emplace_back( file.getFileName() ); + } } } }