mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-167667 Unexpected substitution during block selection paste in java
This commit is contained in:
+6
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,11 +57,13 @@ public abstract class CopyPasteReferenceProcessor<TRef extends PsiElement> exten
|
||||
}
|
||||
|
||||
final ArrayList<ReferenceData> array = new ArrayList<>();
|
||||
int refOffset = 0; // this is an offset delta for conversion from absolute offset to an offset inside clipboard contents
|
||||
for (int j = 0; j < startOffsets.length; j++) {
|
||||
final int startOffset = startOffsets[j];
|
||||
for (final PsiElement element : CollectHighlightsUtil.getElementsInRange(file, startOffset, endOffsets[j])) {
|
||||
addReferenceData(file, startOffset, element, array);
|
||||
refOffset += startOffsets[j];
|
||||
for (final PsiElement element : CollectHighlightsUtil.getElementsInRange(file, startOffsets[j], endOffsets[j])) {
|
||||
addReferenceData(file, refOffset, element, array);
|
||||
}
|
||||
refOffset -= endOffsets[j] + 1; // 1 accounts for line break inserted between contents corresponding to different carets
|
||||
}
|
||||
|
||||
if (array.isEmpty()) {
|
||||
|
||||
+7
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -46,16 +46,20 @@ public class CopyPasteFoldingProcessor extends CopyPastePostProcessor<FoldingTra
|
||||
final FoldRegion[] regions = editor.getFoldingModel().getAllFoldRegions();
|
||||
for (final FoldRegion region : regions) {
|
||||
if (!region.isValid()) continue;
|
||||
int refOffset = 0;
|
||||
for (int j = 0; j < startOffsets.length; j++) {
|
||||
refOffset += startOffsets[j];
|
||||
if (startOffsets[j] <= region.getStartOffset() && region.getEndOffset() <= endOffsets[j]) {
|
||||
list.add(
|
||||
new FoldingData(
|
||||
region.getStartOffset() - startOffsets[j],
|
||||
region.getEndOffset() - startOffsets[j],
|
||||
region.getStartOffset() - refOffset, // offsets should be relative to clipboard contents start
|
||||
region.getEndOffset() - refOffset,
|
||||
region.isExpanded()
|
||||
)
|
||||
);
|
||||
break;
|
||||
}
|
||||
refOffset -= endOffsets[j] + 1; // 1 accounts for line break inserted between contents corresponding to different carets
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user