</key>\r
<key\r
commandId="jp.sourceforge.moreemacs.NewLine"\r
- contextId="org.eclipse.ui.contexts.window"\r
+ contextId="org.eclipse.ui.textEditorScope"\r
schemeId="jp.sourceforge.moreemacs.moreEmacsAcceleratorConfiguration"\r
sequence="M1+M">\r
</key>\r
schemeId="jp.sourceforge.moreemacs.moreEmacsAcceleratorConfiguration"\r
sequence="M1+C M1+C">\r
</key>\r
+ <key\r
+ commandId="jp.sourceforge.moreemacs.CommentRegion"\r
+ contextId="org.eclipse.ui.textEditorScope"\r
+ schemeId="jp.sourceforge.moreemacs.moreEmacsAcceleratorConfiguration"\r
+ sequence="M1+U M1+C M1+C">\r
+ </key>\r
</extension>\r
\r
</plugin>\r
package jp.sourceforge.moreemacs.handlers;\r
\r
import org.eclipse.core.commands.Command;\r
+import org.eclipse.jface.text.ITextSelection;\r
import org.eclipse.ui.commands.ICommandService;\r
import org.eclipse.ui.handlers.IHandlerService;\r
\r
public final class CommentRegionExecution extends TextEditorExecution {\r
@Override\r
public void execute() throws Exception {\r
+ Command command = getEnabledToggleCommentCommand();\r
+ if(command == null) {\r
+ return;\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
+\r
+ ITextSelection selection = getSelection(false);\r
+ textViewer.setSelectedRange(selection.getOffset()+selection.getLength(), 0);\r
+ }\r
+ \r
+ private Command getEnabledToggleCommentCommand() {\r
ICommandService commandService =\r
(ICommandService)textEditor.getSite().getService(ICommandService.class);\r
for(Command command: commandService.getDefinedCommands()) {\r
- if(!isEnabledToggleCommentCommand(command)) {\r
- continue;\r
+ if(isEnabledToggleCommentCommand(command)) {\r
+ return command;\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
- return;\r
}\r
+ return null;\r
}\r
\r
private boolean isEnabledToggleCommentCommand(Command command) {\r