OSDN Git Service

update
authorquiver2k <quiver2k@users.sourceforge.jp>
Wed, 29 Jul 2009 18:31:24 +0000 (03:31 +0900)
committerquiver2k <quiver2k@users.sourceforge.jp>
Wed, 29 Jul 2009 18:31:24 +0000 (03:31 +0900)
jp.sourceforge.moreemacs/src/jp/sourceforge/moreemacs/handlers/CommentRegionExecution.java

index c59115f..d1059d1 100644 (file)
@@ -11,17 +11,21 @@ public final class CommentRegionExecution extends TextEditorExecution {
         ICommandService commandService =\r
             (ICommandService)textEditor.getSite().getService(ICommandService.class);\r
         for(Command command: commandService.getDefinedCommands()) {\r
-            if(!command.isEnabled()) {\r
-                continue;\r
-            }\r
-            if(!command.getId().endsWith(".toggle.comment")) {\r
+            if(!isEnabledToggleCommentCommand(command)) {\r
                 continue;\r
             }\r
+            \r
+            // if the selection is empty, the marked region will be new selection.\r
             getSelection(true);\r
+            \r
             IHandlerService handlerService =\r
                 (IHandlerService)textEditor.getSite().getService(IHandlerService.class);\r
             handlerService.executeCommand(command.getId(), null);\r
-            break;\r
+            return;\r
         }\r
     }\r
+    \r
+    private boolean isEnabledToggleCommentCommand(Command command) {\r
+        return command.isEnabled() && command.getId().endsWith(".toggle.comment");\r
+    }\r
 }\r