Skip to content

Commit

Permalink
Fix NPE when searching in open file which is linked multiple times (e…
Browse files Browse the repository at this point in the history
…clipse-platform#60)

see eclipse-platform/eclipse.platform.text#30 (comment)

Co-authored-by: Joerg Kubitz <jkubitz-eclipse@gmx.de>
  • Loading branch information
jukzi and EcljpseB0T committed Jul 25, 2022
1 parent 7d0476f commit 398e2c6
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ public IStatus processFile(List<IFile> sameFiles, IProgressMonitor monitor) {
}

List<TextSearchMatchAccess> occurences;
CharSequence charsequence = null;
CharSequence charsequence;

IDocument document= getOpenDocument(file, getDocumentsInEditors());
if (document != null) {
DocumentCharSequence documentCharSequence = new DocumentCharSequence(document);
charsequence = new DocumentCharSequence(document);
// assume all documents are non-binary
occurences = locateMatches(file, documentCharSequence, matcher, monitor);
occurences = locateMatches(file, charsequence, matcher, monitor);
} else {
try {
charsequence = fileCharSequenceProvider.newCharSequence(file);
Expand All @@ -238,10 +238,9 @@ public IStatus processFile(List<IFile> sameFiles, IProgressMonitor monitor) {
}
fCollector.flushMatches(duplicateFiles);
}
if (charsequence != null) {
if (document == null) {
try {
fileCharSequenceProvider.releaseCharSequence(charsequence);
charsequence = null;
} catch (IOException e) {
SearchPlugin.log(e);
}
Expand Down

0 comments on commit 398e2c6

Please sign in to comment.