ADD: enable watching real path in TFileView

This commit is contained in:
rich2014 2024-12-28 20:36:12 +08:00
commit 3ecba99193
2 changed files with 8 additions and 4 deletions

View file

@ -3335,6 +3335,7 @@ end;
procedure TFileView.EnableWatcher(Enable: Boolean); procedure TFileView.EnableWatcher(Enable: Boolean);
var var
WatchFilter: TFSWatchFilter; WatchFilter: TFSWatchFilter;
realPath: String;
begin begin
if Enable then if Enable then
begin begin
@ -3362,14 +3363,16 @@ begin
if WatchFilter <> [] then if WatchFilter <> [] then
begin begin
FWatchPath := CurrentPath; FWatchPath := CurrentPath;
if TFileSystemWatcher.AddWatch(FWatchPath, WatchFilter, @WatcherEvent, self) = False then realPath:= (FileSource as TFileSystemFileSource).GetRealPath(FWatchPath);
if TFileSystemWatcher.AddWatch(realPath, WatchFilter, @WatcherEvent, self) = False then
FWatchPath := EmptyStr; FWatchPath := EmptyStr;
end; end;
end; end;
end end
else else
begin begin
TFileSystemWatcher.RemoveWatch(FWatchPath, @WatcherEvent); realPath:= (FileSource as TFileSystemFileSource).GetRealPath(FWatchPath);
TFileSystemWatcher.RemoveWatch(realPath, @WatcherEvent);
FWatchPath := EmptyStr; FWatchPath := EmptyStr;
end; end;
end; end;
@ -3451,6 +3454,7 @@ procedure TFileView.WatcherEvent(const EventData: TFSWatcherEventData);
var var
CurrentTime: TDateTime; CurrentTime: TDateTime;
AddToPending: Boolean; AddToPending: Boolean;
virtualPath: String;
begin begin
if (not FReloadNeeded) and CheckIfDelayReload then if (not FReloadNeeded) and CheckIfDelayReload then
begin begin
@ -3458,9 +3462,10 @@ begin
FReloadNeeded:= True; FReloadNeeded:= True;
Exit; Exit;
end; end;
virtualPath:= (FileSource as TFileSystemFileSource).GetVirtualPath(EventData.Path);
if not (csDestroying in ComponentState) and if not (csDestroying in ComponentState) and
not FReloadNeeded and not FReloadNeeded and
String(IncludeTrailingPathDelimiter(EventData.Path)).StartsWith(CurrentPath) then String(IncludeTrailingPathDelimiter(virtualPath)).StartsWith(CurrentPath) then
begin begin
if GetCurrentWorkType = fvwtCreate then if GetCurrentWorkType = fvwtCreate then
begin begin

View file

@ -691,7 +691,6 @@ const
'MainForm.HorzSplit', 'MainForm.HorzSplit',
'MainForm.SwapPanels', 'MainForm.SwapPanels',
'MainForm.Cloud',
'MainForm.ShowMode', 'MainForm.ShowMode',
'NSToolbarFlexibleSpaceItem', 'NSToolbarFlexibleSpaceItem',
'MainForm.Share', 'MainForm.Share',