How do you implement refactoring.copyHandler for Specific Files?
Unlike the moveFileHandler, refactoring.copyHandler seems to be an all or nothing handler expected to handle all files/directories being copied or none.
I am thinking of implementing my copy handler by marking it’s order as “first” in the registration. Handling all Markdown files then creating an elements array with all unhandled files and querying other refactoring.copyHandler extensions, following my handler in the extensions list for the unhandled files. CopyFilesOrDirectories handler should be last in the list and will catch whatever is left over.
That way all other copy handlers get a chance to process their files.
I will also need to handle directory recursion so that no downstream handler copies any Markdown files without my handler’s involvement.
Seems a bit involved since all copy handlers have to practically do the same thing to ensure everyone’s custom language files get processed.
Is this the correct approach?
Please sign in to leave a comment.
After looking at the implementation and considering the approach I see no way to implement copy handler which will handle Markdown files and let other files through since each handler is responsible for querying the user with a custom dialog for its own file specifics.
One option would be to capture which files/directories are being copied in the
canCopy()method of the handler, then watch for new files being created and match them to source files and apply adjustments after file creation notification for each file.Single file copy would be handled by the copyHandler to allow for file name change capturing.
Does this approach make sense?