12 changes: 10 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1004,6 +1004,14 @@ testCM("wrappingInlineWidget", function(cm) {
eq(curR.bottom, cur1.bottom);
}, {value: "1 2 3 xxx 4", lineWrapping: true});

testCM("showEmptyWidgetSpan", function(cm) {
var marker = cm.markText(Pos(0, 2), Pos(0, 2), {
clearWhenEmpty: false,
replacedWith: document.createTextNode("X")
});
eq(cm.display.view[0].text.textContent, "abXc");
}, {value: "abc"});

testCM("changedInlineWidget", function(cm) {
cm.setSize("10em");
var w = document.createElement("span");
Expand Down Expand Up @@ -1324,8 +1332,8 @@ testCM("rtlMovement", function(cm) {
if (cm.getOption("inputStyle") != "textarea") return;
forEach(["خحج", "خحabcخحج", "abخحخحجcd", "abخde", "abخح2342خ1حج", "خ1ح2خح3حxج",
"خحcd", "1خحcd", "abcdeح1ج", "خمرحبها مها!", "foobarر", "خ ة ق",
"<img src=\"/בדיקה3.jpg\">"], function(line) {
var inv = line.charAt(0) == "خ";
"<img src=\"/בדיקה3.jpg\">", "يتم السحب في 05 فبراير 2014"], function(line) {
var inv = line.charCodeAt(0) > 128;
cm.setValue(line + "\n"); cm.execCommand(inv ? "goLineEnd" : "goLineStart");
var cursors = byClassName(cm.getWrapperElement(), "CodeMirror-cursors")[0];
var cursor = cursors.firstChild;
Expand Down
163 changes: 155 additions & 8 deletions test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ testVim('{', function(cm, vim, helpers) {
helpers.doKeys('6', '{');
helpers.assertCursorAt(0, 0);
}, { value: 'a\n\nb\nc\n\nd' });
testVim('paragraph motions', function(cm, vim, helpers) {
testVim('paragraph_motions', function(cm, vim, helpers) {
cm.setCursor(10, 0);
helpers.doKeys('{');
helpers.assertCursorAt(4, 0);
Expand Down Expand Up @@ -984,6 +984,17 @@ testVim('cc_multiply_repeat', function(cm, vim, helpers) {
is(register.linewise);
eq('vim-insert', cm.getOption('keyMap'));
});
testVim('ct', function(cm, vim, helpers) {
cm.setCursor(0, 9);
helpers.doKeys('c', 't', 'w');
eq(' word1 word3', cm.getValue());
helpers.doKeys('<Esc>', 'c', '|');
eq(' word3', cm.getValue());
helpers.assertCursorAt(0, 0);
helpers.doKeys('<Esc>', '2', 'u', 'w', 'h');
helpers.doKeys('c', '2', 'g', 'e');
eq(' wordword3', cm.getValue());
}, { value: ' word1 word2 word3'});
testVim('cc_should_not_append_to_document', function(cm, vim, helpers) {
var expectedLineCount = cm.lineCount();
cm.setCursor(cm.lastLine(), 0);
Expand Down Expand Up @@ -1884,7 +1895,11 @@ testVim('visual_block_move_to_eol', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('<C-v>', 'G', '$');
var selections = cm.getSelections().join();
eq("123,45,6", selections);
eq('123,45,6', selections);
// Checks that with cursor at Infinity, finding words backwards still works.
helpers.doKeys('2', 'k', 'b');
selections = cm.getSelections().join();
eq('1', selections);
}, {value: '123\n45\n6'});
testVim('visual_block_different_line_lengths', function(cm, vim, helpers) {
// test the block selection with lines of different length
Expand Down Expand Up @@ -2712,6 +2727,44 @@ testVim('exCommand_history', function(cm, vim, helpers) {
onKeyDown({keyCode: keyCodes.Up}, input, close);
eq(input, 'sort');
}, {value: ''});
testVim('search_clear', function(cm, vim, helpers) {
var onKeyDown;
var input = '';
var keyCodes = {
Ctrl: 17,
u: 85
};
cm.openDialog = function(template, callback, options) {
onKeyDown = options.onKeyDown;
};
var close = function(newVal) {
if (typeof newVal == 'string') input = newVal;
}
helpers.doKeys('/');
input = 'foo';
onKeyDown({keyCode: keyCodes.Ctrl}, input, close);
onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close);
eq(input, '');
});
testVim('exCommand_clear', function(cm, vim, helpers) {
var onKeyDown;
var input = '';
var keyCodes = {
Ctrl: 17,
u: 85
};
cm.openDialog = function(template, callback, options) {
onKeyDown = options.onKeyDown;
};
var close = function(newVal) {
if (typeof newVal == 'string') input = newVal;
}
helpers.doKeys(':');
input = 'foo';
onKeyDown({keyCode: keyCodes.Ctrl}, input, close);
onKeyDown({keyCode: keyCodes.u, ctrlKey: true}, input, close);
eq(input, '');
});
testVim('.', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('2', 'd', 'w');
Expand Down Expand Up @@ -3659,17 +3712,111 @@ testVim('set_string', function(cm, vim, helpers) {
eq('c', CodeMirror.Vim.getOption('testoption'));
});
testVim('ex_set_string', function(cm, vim, helpers) {
CodeMirror.Vim.defineOption('testoption', 'a', 'string');
CodeMirror.Vim.defineOption('testopt', 'a', 'string');
// Test default value is set.
eq('a', CodeMirror.Vim.getOption('testoption'));
eq('a', CodeMirror.Vim.getOption('testopt'));
try {
// Test fail to set 'notestoption'
helpers.doEx('set notestoption=b');
// Test fail to set 'notestopt'
helpers.doEx('set notestopt=b');
fail();
} catch (expected) {};
// Test setOption
helpers.doEx('set testoption=c')
eq('c', CodeMirror.Vim.getOption('testoption'));
helpers.doEx('set testopt=c')
eq('c', CodeMirror.Vim.getOption('testopt'));
helpers.doEx('set testopt=c')
eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global
eq('c', CodeMirror.Vim.getOption('testopt')); // global
// Test setOption global
helpers.doEx('setg testopt=d')
eq('c', CodeMirror.Vim.getOption('testopt', cm));
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'}));
eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'}));
eq('d', CodeMirror.Vim.getOption('testopt'));
// Test setOption local
helpers.doEx('setl testopt=e')
eq('e', CodeMirror.Vim.getOption('testopt', cm));
eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'}));
eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'}));
eq('d', CodeMirror.Vim.getOption('testopt'));
});
testVim('ex_set_callback', function(cm, vim, helpers) {
var global;

function cb(val, cm, cfg) {
if (val === undefined) {
// Getter
if (cm) {
return cm._local;
} else {
return global;
}
} else {
// Setter
if (cm) {
cm._local = val;
} else {
global = val;
}
}
}

CodeMirror.Vim.defineOption('testopt', 'a', 'string', cb);
// Test default value is set.
eq('a', CodeMirror.Vim.getOption('testopt'));
try {
// Test fail to set 'notestopt'
helpers.doEx('set notestopt=b');
fail();
} catch (expected) {};
// Test setOption (Identical to the string tests, but via callback instead)
helpers.doEx('set testopt=c')
eq('c', CodeMirror.Vim.getOption('testopt', cm)); //local || global
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'})); // local
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'})); // global
eq('c', CodeMirror.Vim.getOption('testopt')); // global
// Test setOption global
helpers.doEx('setg testopt=d')
eq('c', CodeMirror.Vim.getOption('testopt', cm));
eq('c', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'}));
eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'}));
eq('d', CodeMirror.Vim.getOption('testopt'));
// Test setOption local
helpers.doEx('setl testopt=e')
eq('e', CodeMirror.Vim.getOption('testopt', cm));
eq('e', CodeMirror.Vim.getOption('testopt', cm, {scope: 'local'}));
eq('d', CodeMirror.Vim.getOption('testopt', cm, {scope: 'global'}));
eq('d', CodeMirror.Vim.getOption('testopt'));
})
testVim('ex_set_filetype', function(cm, vim, helpers) {
CodeMirror.defineMode('test_mode', function() {
return {token: function(stream) {
stream.match(/^\s+|^\S+/);
}};
});
CodeMirror.defineMode('test_mode_2', function() {
return {token: function(stream) {
stream.match(/^\s+|^\S+/);
}};
});
// Test mode is set.
helpers.doEx('set filetype=test_mode');
eq('test_mode', cm.getMode().name);
// Test 'ft' alias also sets mode.
helpers.doEx('set ft=test_mode_2');
eq('test_mode_2', cm.getMode().name);
});
testVim('ex_set_filetype_null', function(cm, vim, helpers) {
CodeMirror.defineMode('test_mode', function() {
return {token: function(stream) {
stream.match(/^\s+|^\S+/);
}};
});
cm.setOption('mode', 'test_mode');
// Test mode is set to null.
helpers.doEx('set filetype=');
eq('null', cm.getMode().name);
});
// TODO: Reset key maps after each test.
testVim('ex_map_key2key', function(cm, vim, helpers) {
Expand Down
95 changes: 95 additions & 0 deletions theme/liquibyte.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.cm-s-liquibyte.CodeMirror {
background-color: #000;
color: #fff;
line-height: 1.2em;
font-size: 1em;
}
.CodeMirror-focused .cm-matchhighlight {
text-decoration: underline;
text-decoration-color: #0f0;
text-decoration-style: wavy;
}
.cm-trailingspace {
text-decoration: line-through;
text-decoration-color: #f00;
text-decoration-style: dotted;
}
.cm-tab {
text-decoration: line-through;
text-decoration-color: #404040;
text-decoration-style: dotted;
}
.cm-s-liquibyte .CodeMirror-gutters { background-color: #262626; border-right: 1px solid #505050; padding-right: 0.8em; }
.cm-s-liquibyte .CodeMirror-gutter-elt div{ font-size: 1.2em; }
.cm-s-liquibyte .CodeMirror-guttermarker { }
.cm-s-liquibyte .CodeMirror-guttermarker-subtle { }
.cm-s-liquibyte .CodeMirror-linenumber { color: #606060; padding-left: 0;}
.cm-s-liquibyte .CodeMirror-cursor { border-left: 1px solid #eee !important; }

.cm-s-liquibyte span.cm-comment { color: #008000; }
.cm-s-liquibyte span.cm-def { color: #ffaf40; font-weight: bold; }
.cm-s-liquibyte span.cm-keyword { color: #c080ff; font-weight: bold; }
.cm-s-liquibyte span.cm-builtin { color: #ffaf40; font-weight: bold; }
.cm-s-liquibyte span.cm-variable { color: #5967ff; font-weight: bold; }
.cm-s-liquibyte span.cm-string { color: #ff8000; }
.cm-s-liquibyte span.cm-number { color: #0f0; font-weight: bold; }
.cm-s-liquibyte span.cm-atom { color: #bf3030; font-weight: bold; }

.cm-s-liquibyte span.cm-variable-2 { color: #007f7f; font-weight: bold; }
.cm-s-liquibyte span.cm-variable-3 { color: #c080ff; font-weight: bold; }
.cm-s-liquibyte span.cm-property { color: #999; font-weight: bold; }
.cm-s-liquibyte span.cm-operator { color: #fff; }

.cm-s-liquibyte span.cm-meta { color: #0f0; }
.cm-s-liquibyte span.cm-qualifier { color: #fff700; font-weight: bold; }
.cm-s-liquibyte span.cm-bracket { color: #cc7; }
.cm-s-liquibyte span.cm-tag { color: #ff0; font-weight: bold; }
.cm-s-liquibyte span.cm-attribute { color: #c080ff; font-weight: bold; }
.cm-s-liquibyte span.cm-error { color: #f00; }

.cm-s-liquibyte .CodeMirror-selected { background-color: rgba(255, 0, 0, 0.25) !important; }

.cm-s-liquibyte span.cm-compilation { background-color: rgba(255, 255, 255, 0.12); }

.cm-s-liquibyte .CodeMirror-activeline-background {background-color: rgba(0, 255, 0, 0.15) !important;}

/* Default styles for common addons */
div.CodeMirror span.CodeMirror-matchingbracket { color: #0f0; font-weight: bold; }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: #f00; font-weight: bold; }
.CodeMirror-matchingtag { background-color: rgba(150, 255, 0, .3); }
/* Scrollbars */
/* Simple */
div.CodeMirror-simplescroll-horizontal div:hover, div.CodeMirror-simplescroll-vertical div:hover {
background-color: rgba(80, 80, 80, .7);
}
div.CodeMirror-simplescroll-horizontal div, div.CodeMirror-simplescroll-vertical div {
background-color: rgba(80, 80, 80, .3);
border: 1px solid #404040;
border-radius: 5px;
}
div.CodeMirror-simplescroll-vertical div {
border-top: 1px solid #404040;
border-bottom: 1px solid #404040;
}
div.CodeMirror-simplescroll-horizontal div {
border-left: 1px solid #404040;
border-right: 1px solid #404040;
}
div.CodeMirror-simplescroll-vertical {
background-color: #262626;
}
div.CodeMirror-simplescroll-horizontal {
background-color: #262626;
border-top: 1px solid #404040;
}
/* Overlay */
div.CodeMirror-overlayscroll-horizontal div, div.CodeMirror-overlayscroll-vertical div {
background-color: #404040;
border-radius: 5px;
}
div.CodeMirror-overlayscroll-vertical div {
border: 1px solid #404040;
}
div.CodeMirror-overlayscroll-horizontal div {
border: 1px solid #404040;
}
2 changes: 1 addition & 1 deletion theme/monokai.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
.cm-s-monokai span.cm-keyword {color: #f92672;}
.cm-s-monokai span.cm-string {color: #e6db74;}

.cm-s-monokai span.cm-variable {color: #a6e22e;}
.cm-s-monokai span.cm-variable {color: #f8f8f2;}
.cm-s-monokai span.cm-variable-2 {color: #9effff;}
.cm-s-monokai span.cm-def {color: #fd971f;}
.cm-s-monokai span.cm-bracket {color: #f8f8f2;}
Expand Down
2 changes: 1 addition & 1 deletion theme/solarized.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ http://ethanschoonover.com/solarized/img/solarized-palette.png
.cm-s-solarized .cm-number { color: #d33682; }
.cm-s-solarized .cm-def { color: #2aa198; }

.cm-s-solarized .cm-variable { color: #268bd2; }
.cm-s-solarized .cm-variable { color: #839496; }
.cm-s-solarized .cm-variable-2 { color: #b58900; }
.cm-s-solarized .cm-variable-3 { color: #6c71c4; }

Expand Down