mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-61148 Fix Show History for selection with local changes
If local changes were adding or removing lines above the selection, "show history for selection" used incorrect selection interval, because it was applied to the latest VCS revision. Shift the ranges using the existing FindBlock functionality applied to the current editor content and the latest repository revision.
This commit is contained in:
@@ -90,6 +90,7 @@ public class SelectedBlockHistoryAction extends AbstractVcsAction {
|
||||
final VcsHistoryDialog vcsHistoryDialog =
|
||||
new VcsHistoryDialog(project,
|
||||
context.getSelectedFiles()[0],
|
||||
context.getEditor(),
|
||||
provider,
|
||||
session,
|
||||
activeVcs,
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.DiffManager;
|
||||
import com.intellij.openapi.diff.DiffPanel;
|
||||
import com.intellij.openapi.diff.SimpleContent;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileTypes.FileType;
|
||||
import com.intellij.openapi.help.HelpManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -56,6 +57,7 @@ import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
private final Editor myEditor;
|
||||
private final int mySelectionStart;
|
||||
private final int mySelectionEnd;
|
||||
|
||||
@@ -115,7 +117,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
|
||||
public VcsHistoryDialog(Project project,
|
||||
final VirtualFile file,
|
||||
final VcsHistoryProvider vcsHistoryProvider,
|
||||
Editor editor, final VcsHistoryProvider vcsHistoryProvider,
|
||||
VcsHistorySession session,
|
||||
AbstractVcs vcs,
|
||||
int selectionStart,
|
||||
@@ -123,6 +125,7 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
final String title, final CachedRevisionsContents cachedContents){
|
||||
super(project, true);
|
||||
myProject = project;
|
||||
myEditor = editor;
|
||||
mySelectionStart = selectionStart;
|
||||
mySelectionEnd = selectionEnd;
|
||||
myCachedContents = cachedContents;
|
||||
@@ -463,8 +466,10 @@ public class VcsHistoryDialog extends DialogWrapper implements DataProvider {
|
||||
|
||||
final String revisionContent = getContentOf(revision);
|
||||
if (revisionContent == null) return null;
|
||||
if (index == 0)
|
||||
myRevisionToContentMap.put(revision, new Block(revisionContent, mySelectionStart, mySelectionEnd));
|
||||
if (index == 0) {
|
||||
Block currentBlock = new Block(myEditor.getDocument().getText(), mySelectionStart, mySelectionEnd);
|
||||
myRevisionToContentMap.put(revision, new FindBlock(revisionContent, currentBlock).getBlockInThePrevVersion());
|
||||
}
|
||||
else {
|
||||
Block prevBlock = getBlock(myRevisions.get(index - 1));
|
||||
if (prevBlock == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user