DiffView: looks like Intellij Cache VirtualFile Content

Hi all,
I implemented a feature to show diff from two remote branches using a custom virtual file implementation. I found a strange behaviour in the DiffView and I don’t know if it’s a problem of my implementation or a feature.

Now the problem is this one:

  1. Show the diff of file A
  2. Change the file A (commit & push)
  3. Open diff for file A again
  4. The content is the same

I debug the code and the file is read from remote correctly, so I think is cached somewhere

But if I change it to a LightVirtualFile the changes are shown. Do I have to do something special for equals and hash? At the moment I define 2 files the same if have the same path, but maybe I should consider timestamps and/or content.

Mainly I create a Diff View using this command:

DiffManager.getInstance().showDiff(project, diffRequest, DiffDialogHints.DEFAULT)

and the diff request is created in this way:

DiffRequestFactory.getInstance().createFromFiles(project, targetFile, sourceFile).also {
            //adding some context information in User data
        }
1 Like