mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
no hyperlink cursor in the empty space after the link
This commit is contained in:
@@ -33,7 +33,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.Navigatable;
|
||||
@@ -129,16 +129,12 @@ public class TargetElementUtilBase {
|
||||
|
||||
public static boolean inVirtualSpace(Editor editor, int offset) {
|
||||
if (offset == editor.getCaretModel().getOffset()) {
|
||||
return inVirtualSpace(editor, editor.getCaretModel().getLogicalPosition());
|
||||
return EditorUtil.inVirtualSpace(editor, editor.getCaretModel().getLogicalPosition());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean inVirtualSpace(Editor editor, LogicalPosition logicalPosition) {
|
||||
return !editor.offsetToLogicalPosition(editor.logicalPositionToOffset(logicalPosition)).equals(logicalPosition);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement findTargetElement(Editor editor, int flags, int offset) {
|
||||
Project project = editor.getProject();
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.intellij.openapi.editor.LogicalPosition;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.TextAttributesKey;
|
||||
import com.intellij.openapi.editor.event.*;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.editor.markup.*;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManagerAdapter;
|
||||
@@ -506,7 +507,7 @@ public class CtrlMouseHandler extends AbstractProjectComponent {
|
||||
if (file == null) return;
|
||||
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
|
||||
|
||||
if (TargetElementUtilBase.inVirtualSpace(myEditor, myPosition)) {
|
||||
if (EditorUtil.inVirtualSpace(myEditor, myPosition)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.intellij.openapi.editor.event.EditorMouseAdapter;
|
||||
import com.intellij.openapi.editor.event.EditorMouseEvent;
|
||||
import com.intellij.openapi.editor.ex.EditorEx;
|
||||
import com.intellij.openapi.editor.ex.MarkupModelEx;
|
||||
import com.intellij.openapi.editor.ex.util.EditorUtil;
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer;
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
@@ -72,8 +73,12 @@ public class EditorHyperlinkSupport {
|
||||
public void mouseReleased(final EditorMouseEvent e) {
|
||||
final MouseEvent mouseEvent = e.getMouseEvent();
|
||||
if (mouseEvent.getButton() == MouseEvent.BUTTON1 && !mouseEvent.isPopupTrigger()) {
|
||||
int offset = myEditor.logicalPositionToOffset(myEditor.xyToLogicalPosition(e.getMouseEvent().getPoint()));
|
||||
RangeHighlighter range = findLinkRangeAt(offset);
|
||||
LogicalPosition logical = myEditor.xyToLogicalPosition(e.getMouseEvent().getPoint());
|
||||
if (EditorUtil.inVirtualSpace(editor, logical)) {
|
||||
return;
|
||||
}
|
||||
|
||||
RangeHighlighter range = findLinkRangeAt(myEditor.logicalPositionToOffset(logical));
|
||||
final HyperlinkInfo info = myHighlighterToMessageInfoMap.get(range);
|
||||
if (info != null) {
|
||||
info.navigate(project);
|
||||
@@ -252,6 +257,10 @@ public class EditorHyperlinkSupport {
|
||||
@Nullable
|
||||
public HyperlinkInfo getHyperlinkInfoByPoint(final Point p) {
|
||||
final LogicalPosition pos = myEditor.xyToLogicalPosition(new Point(p.x, p.y));
|
||||
if (EditorUtil.inVirtualSpace(myEditor, pos)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getHyperlinkInfoByLineAndCol(pos.line, pos.column);
|
||||
}
|
||||
|
||||
|
||||
@@ -614,6 +614,10 @@ public class EditorUtil {
|
||||
? !e.isControlDown() && e.isMetaDown() && !e.isAltDown() && !e.isShiftDown()
|
||||
: e.isControlDown() && !e.isMetaDown() && !e.isAltDown() && !e.isShiftDown();
|
||||
}
|
||||
|
||||
public static boolean inVirtualSpace(Editor editor, LogicalPosition logicalPosition) {
|
||||
return !editor.offsetToLogicalPosition(editor.logicalPositionToOffset(logicalPosition)).equals(logicalPosition);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user