From 94dbd1ee65b7e066b84aa3bcb104f71667fb6dbe Mon Sep 17 00:00:00 2001 From: Alexey Kudravtsev Date: Mon, 24 Jun 2013 13:33:54 +0400 Subject: [PATCH] EA-47125 - NPE: UnSelectWordHandler.doAction --- .../editorActions/UnSelectWordHandler.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java index 1fc5e46dfb52..967a672b7452 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/UnSelectWordHandler.java @@ -83,12 +83,19 @@ public class UnSelectWordHandler extends EditorActionHandler { } } - while (element instanceof PsiWhiteSpace) { - if (element.getNextSibling() == null) { + if (element instanceof PsiWhiteSpace) { + PsiElement nextSibling = element.getNextSibling(); + if (nextSibling == null) { element = element.getParent(); + if (element == null || element instanceof PsiFile) { + return; + } + nextSibling = element.getNextSibling(); + if (nextSibling == null) { + return; + } } - - element = element.getNextSibling(); + element = nextSibling; cursorOffset = element.getTextRange().getStartOffset(); }