From 12b0bf5df4217463fae7c0d384591bf8c2c860e6 Mon Sep 17 00:00:00 2001 From: irengrig Date: Wed, 13 Jul 2011 14:47:07 +0400 Subject: [PATCH] fix test --- .../openapi/diff/impl/patch/TextPatchBuilder.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java index f73dfc3d10d1..2f79f6e63e86 100644 --- a/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java +++ b/platform/vcs-api/src/com/intellij/openapi/diff/impl/patch/TextPatchBuilder.java @@ -114,8 +114,8 @@ public class TextPatchBuilder { if (afterContent == null) { throw new VcsException("Failed to fetch new content for changed file " + afterRevision.getPath().getPath()); } - String[] beforeLines = new LineTokenizer(beforeContent).execute(); - String[] afterLines = new LineTokenizer(afterContent).execute(); + String[] beforeLines = tokenize(beforeContent); + String[] afterLines = tokenize(afterContent); DiffFragment[] woFormattingBlocks; DiffFragment[] step1lineFragments; @@ -181,6 +181,10 @@ public class TextPatchBuilder { return result; } + private static String[] tokenize(String text) { + return text.length() == 0 ? new String[]{text} : new LineTokenizer(text).execute(); + } + private FilePatch buildBinaryPatch(final String basePath, final AirContentRevision beforeRevision, final AirContentRevision afterRevision) throws VcsException { @@ -218,7 +222,7 @@ public class TextPatchBuilder { if (content == null) { throw new VcsException("Failed to fetch content for added file " + afterRevision.getPath().getPath()); } - String[] lines = new LineTokenizer(content).execute(); + String[] lines = tokenize(content); TextFilePatch result = buildPatchHeading(basePath, afterRevision, afterRevision); PatchHunk hunk = new PatchHunk(-1, -1, 0, lines.length); for(String line: lines) { @@ -234,7 +238,7 @@ public class TextPatchBuilder { if (content == null) { throw new VcsException("Failed to fetch old content for deleted file " + beforeRevision.getPath().getPath()); } - String[] lines = new LineTokenizer(content).execute(); + String[] lines = tokenize(content); TextFilePatch result = buildPatchHeading(basePath, beforeRevision, beforeRevision); PatchHunk hunk = new PatchHunk(0, lines.length, -1, -1); for(String line: lines) {