if line comment prefix is followed by a single space, uncomment line action deletes that space (PY-980)

This commit is contained in:
Dmitry Jemerov
2010-05-13 18:13:19 +04:00
parent 96f6e7d4ce
commit ee323fe9d3
3 changed files with 19 additions and 0 deletions

View File

@@ -0,0 +1 @@
this is commented

View File

@@ -0,0 +1 @@
# this is commented

View File

@@ -1,5 +1,9 @@
package com.jetbrains.python;
import com.intellij.codeInsight.generation.actions.CommentByLineCommentAction;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.ActionManager;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.IdeActions;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.command.CommandProcessor;
@@ -81,6 +85,19 @@ public class PyEditingTest extends PyLightFixtureTestCase {
myFixture.checkResultByFile("/editing/smartUnindent.after.py", true);
}
public void testUncommentWithSpace() throws Exception { // PY-980
myFixture.configureByFile("/editing/uncommentWithSpace.before.py");
myFixture.getEditor().getCaretModel().moveToLogicalPosition(new LogicalPosition(0, 1));
CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() {
public void run() {
CommentByLineCommentAction action = new CommentByLineCommentAction();
action.actionPerformed(new AnActionEvent(null, DataManager.getInstance().getDataContext(), "", action.getTemplatePresentation(),
ActionManager.getInstance(), 0));
}
}, "", null);
myFixture.checkResultByFile("/editing/uncommentWithSpace.after.py", true);
}
private String doTestTyping(final String text, final int offset, final char character) {
final PsiFile file = ApplicationManager.getApplication().runWriteAction(new Computable<PsiFile>() {
public PsiFile compute() {