mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-08-01 15:59:06 +02:00
VIM-679 Parse characters less than \u0020 as <C-$CHAR>
This commit is contained in:
parent
f71d6c7fab
commit
b17a592c95
src/com/maddyhome/idea/vim/helper
test/org/jetbrains/plugins/ideavim
@ -151,7 +151,17 @@ public class StringHelper {
|
||||
specialKeyBuilder = new StringBuilder();
|
||||
}
|
||||
else {
|
||||
result.add(isControlCharacter(c) ? getKeyStroke(c, 0) : getKeyStroke(c));
|
||||
final KeyStroke stroke;
|
||||
if (c == '\t' || c == '\n') {
|
||||
stroke = getKeyStroke(c, 0);
|
||||
}
|
||||
else if (isControlCharacter(c)) {
|
||||
stroke = getKeyStroke(c + 'A' - 1, CTRL_MASK);
|
||||
}
|
||||
else {
|
||||
stroke = getKeyStroke(c);
|
||||
}
|
||||
result.add(stroke);
|
||||
}
|
||||
break;
|
||||
case ESCAPE:
|
||||
|
@ -210,19 +210,21 @@ public class MapCommandTest extends VimTestCase {
|
||||
myFixture.checkResult("#\n");
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
typeText(commandToKeys("imap"));
|
||||
assertExOutput("i # * X<BS>#\n");
|
||||
assertExOutput("i # * X<C-H>#\n");
|
||||
}
|
||||
|
||||
// VIM-679 |:map|
|
||||
public void testCancelCharacterInVimRc() {
|
||||
configureByText("foo\n");
|
||||
configureByText("<caret>foo\n" +
|
||||
"bar\n");
|
||||
VimScriptParser.executeText("map \u0018i dd\n");
|
||||
typeText(parseKeys("i", "#", "<Esc>"));
|
||||
myFixture.checkResult("#foo\n");
|
||||
myFixture.checkResult("#foo\n" +
|
||||
"bar\n");
|
||||
assertMode(CommandState.Mode.COMMAND);
|
||||
//typeText(commandToKeys("map"));
|
||||
//assertExOutput(" <C-X>i dd\n");
|
||||
//typeText(parseKeys("<C-X>i"));
|
||||
//myFixture.checkResult("\n");
|
||||
typeText(commandToKeys("map"));
|
||||
assertExOutput(" <C-X>i dd\n");
|
||||
typeText(parseKeys("<C-X>i"));
|
||||
myFixture.checkResult("bar\n");
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -69,10 +70,29 @@ public class StringHelperTest extends TestCase {
|
||||
assertTypedKeyStroke('|', "<Bar>");
|
||||
}
|
||||
|
||||
// VIM-679
|
||||
public void testControlXCharacter() {
|
||||
assertPressedKeyStroke("control X", "\u0018");
|
||||
}
|
||||
|
||||
public void testControlBoundCharacters() {
|
||||
assertKeyStroke(KeyStroke.getKeyStroke('@', InputEvent.CTRL_MASK), "\u0000");
|
||||
assertKeyStroke(KeyStroke.getKeyStroke('_', InputEvent.CTRL_MASK), "\u001F");
|
||||
}
|
||||
|
||||
public void testControlExceptionCharacters() {
|
||||
assertPressedKeyStroke("TAB", "\t"); // U+0009
|
||||
assertPressedKeyStroke("ENTER", "\n"); // U+000A
|
||||
}
|
||||
|
||||
private void assertPressedKeyStroke(@NotNull String expected, @NotNull String actual) {
|
||||
assertEquals(KeyStroke.getKeyStroke(expected), parseKeyStroke(actual));
|
||||
}
|
||||
|
||||
private void assertKeyStroke(@NotNull KeyStroke expected, @NotNull String actual) {
|
||||
assertEquals(expected, parseKeyStroke(actual));
|
||||
}
|
||||
|
||||
private void assertTypedKeyStroke(char expected, @NotNull String actual) {
|
||||
assertEquals(KeyStroke.getKeyStroke(expected), parseKeyStroke(actual));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user