Skip to content

Support for File Creation #47

@Pumuckline83

Description

@Pumuckline83

Hi there, I ran into a problem when I tried to create a unified diff for the creation of a new file, which seams not to be supported by your library right now.

As far as I can see, this feature is very easy to implement and could help others as well.

It requires just a small change in the UnifiedDiffUtils.processDeltas() method, some changes in the method signatures to get the info about the new File creation into the methods and maybe another method to keep calls to old method signature running with default values.

Actually it just those few lines in the main logic that could cover file creation:

if (createNewFile) {
            origStart = 0; // the 0 here will trigger the creation of the new file
 } else {
            origStart = curDelta.getSource().getPosition() + 1 - contextSize;
            // NOTE: +1 to overcome the 0-offset Position
            if (origStart < 1) {
                origStart = 1;
            }
 }

Cheers, Eva

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions