mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-116706 Unselect word at caret doesn't work reversing through lambdarized anonymous class
This commit is contained in:
+10
-2
@@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.FoldRegion;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -54,7 +55,7 @@ public class UnSelectWordHandler extends EditorActionHandler {
|
||||
}
|
||||
|
||||
|
||||
private static void doAction(Editor editor, PsiFile file) {
|
||||
private static void doAction(final Editor editor, PsiFile file) {
|
||||
if (file instanceof PsiCompiledFile) {
|
||||
file = ((PsiCompiledFile)file).getDecompiledPsiFile();
|
||||
if (file == null) return;
|
||||
@@ -108,7 +109,9 @@ public class UnSelectWordHandler extends EditorActionHandler {
|
||||
SelectWordUtil.processRanges(element, text, cursorOffset, editor, new Processor<TextRange>() {
|
||||
@Override
|
||||
public boolean process(TextRange range) {
|
||||
if (selectionRange.contains(range) && !range.equals(selectionRange) && (range.contains(finalCursorOffset) || finalCursorOffset == range.getEndOffset())) {
|
||||
if (selectionRange.contains(range) && !range.equals(selectionRange) &&
|
||||
(range.contains(finalCursorOffset) || finalCursorOffset == range.getEndOffset()) &&
|
||||
!isOffsetCollapsed(range.getStartOffset()) && !isOffsetCollapsed(range.getEndOffset())) {
|
||||
if (maximumRange.get() == null || range.contains(maximumRange.get())) {
|
||||
maximumRange.set(range);
|
||||
}
|
||||
@@ -116,6 +119,11 @@ public class UnSelectWordHandler extends EditorActionHandler {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isOffsetCollapsed(int offset) {
|
||||
FoldRegion region = editor.getFoldingModel().getCollapsedRegionAtOffset(offset);
|
||||
return region != null && region.getStartOffset() != offset && region.getEndOffset() != offset;
|
||||
}
|
||||
});
|
||||
|
||||
TextRange range = maximumRange.get();
|
||||
|
||||
Reference in New Issue
Block a user