mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-110607 Double clicking space/tab characters should select all space/tab characters until it encounters another type of character
Much better Expand Selection behavior when some whitespaces are already selected GitOrigin-RevId: f5042c1c1487a41d701e30026a7b33f5ae1e8450
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9c4678616b
commit
4196832b4b
+1
-1
@@ -127,7 +127,7 @@ public class SelectWordHandler extends EditorActionHandler.ForEachCaret {
|
||||
}
|
||||
}
|
||||
|
||||
if (!(element instanceof PsiWhiteSpace && SelectWordUtil.canWhiteSpaceBeExpanded((PsiWhiteSpace) element, caretOffset))) {
|
||||
if (!(element instanceof PsiWhiteSpace && SelectWordUtil.canWhiteSpaceBeExpanded((PsiWhiteSpace) element, caretOffset, caret))) {
|
||||
while (element instanceof PsiWhiteSpace || element != null && StringUtil.isEmptyOrSpaces(element.getText())) {
|
||||
while (element.getNextSibling() == null) {
|
||||
if (element instanceof PsiFile) return null;
|
||||
|
||||
@@ -5,6 +5,7 @@ package com.intellij.codeInsight.editorActions;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.FileASTNode;
|
||||
import com.intellij.lexer.Lexer;
|
||||
import com.intellij.openapi.editor.Caret;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.actions.EditorActionUtil;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
@@ -269,11 +270,13 @@ public final class SelectWordUtil {
|
||||
* Returns if there is any expandable whitespace belonging to the given psiWhiteSpace
|
||||
* by any side of a caret at specified cursorPosition
|
||||
*/
|
||||
public static boolean canWhiteSpaceBeExpanded(PsiWhiteSpace psiWhiteSpace, int cursorPosition) {
|
||||
Character charBeforeCursor = getCharBeforeCursorInPsiElement(psiWhiteSpace, cursorPosition);
|
||||
public static boolean canWhiteSpaceBeExpanded(PsiWhiteSpace psiWhiteSpace, int cursorPosition, Caret caret) {
|
||||
int beforeOffset = caret.hasSelection()? caret.getSelectionStart() : cursorPosition;
|
||||
Character charBeforeCursor = getCharBeforeCursorInPsiElement(psiWhiteSpace, beforeOffset);
|
||||
if (charBeforeCursor != null && isExpandableWhiteSpace(charBeforeCursor)) return true;
|
||||
|
||||
Character charAfterCursor = getCharAfterCursorInPsiElement(psiWhiteSpace, cursorPosition);
|
||||
int afterOffset = caret.hasSelection()? caret.getSelectionEnd() : cursorPosition;
|
||||
Character charAfterCursor = getCharAfterCursorInPsiElement(psiWhiteSpace, afterOffset);
|
||||
if (charAfterCursor != null && isExpandableWhiteSpace(charAfterCursor)) return true;
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user