Browse Source

Bug fix: Pasting files using local tree view context menu pastes them to the current directory, instead of the selected one

Source commit: 7dcca2722569e65db24b8e1a5b694ddaf8ccaffe
Martin Prikryl 1 week ago
parent
commit
6fabd18286
1 changed files with 6 additions and 11 deletions
  1. 6 11
      source/packages/filemng/DriveView.pas

+ 6 - 11
source/packages/filemng/DriveView.pas

@@ -276,7 +276,7 @@ type
     function DDExecute: TDragResult; override;
 
     function CanPasteFromClipBoard: Boolean;
-    function PasteFromClipBoard(TargetPath: string = ''): Boolean;
+    procedure PasteFromClipBoard(Node: TTreeNode);
     procedure PerformDragDropFileOperation(Node: TTreeNode; Effect: Integer); override;
 
   public
@@ -2675,7 +2675,7 @@ begin
   if Verb = shcCopy then LastClipBoardOperation := cboCopy
     else
   if Verb = shcPaste then
-    PasteFromClipBoard(NodePathName(Node));
+    PasteFromClipBoard(Node);
 
   DropTarget := nil;
 
@@ -2942,32 +2942,27 @@ begin
   end;
 end; {CanPasteFromClipBoard}
 
-function TDriveView.PasteFromClipBoard(TargetPath: String = ''): Boolean;
+procedure TDriveView.PasteFromClipBoard(Node: TTreeNode);
 begin
   ClearDragFileList(FDragDropFilesEx.FileList);
-  Result := False;
-  if CanPasteFromClipBoard and {MP}FDragDropFilesEx.GetFromClipBoard{/MP}
-    then
+  if CanPasteFromClipBoard and FDragDropFilesEx.GetFromClipBoard then
   begin
-    if TargetPath = '' then
-      TargetPath := NodePathName(Selected);
     case LastClipBoardOperation of
       cboCopy,
       cboNone:
         begin
-          PerformDragDropFileOperation(Selected, DROPEFFECT_COPY);
+          PerformDragDropFileOperation(Node, DROPEFFECT_COPY);
           if Assigned(FOnDDExecuted) then
             FOnDDExecuted(Self, DROPEFFECT_COPY);
         end;
       cboCut:
         begin
-          PerformDragDropFileOperation(Selected, DROPEFFECT_MOVE);
+          PerformDragDropFileOperation(Node, DROPEFFECT_MOVE);
           if Assigned(FOnDDExecuted) then
             FOnDDExecuted(Self, DROPEFFECT_MOVE);
           EmptyClipBoard;
         end;
     end;
-    Result := True;
   end;
 end; {PasteFromClipBoard}