summaryrefslogtreecommitdiff
path: root/public/js/index.js
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-02-01 00:42:30 -0600
committerCheng-Han, Wu2016-02-01 00:42:30 -0600
commitce8f9b695cc524ee4678216912b6c899ca9976b7 (patch)
treed410e952b56cfcc128a1a8535c6e25af50a2fe98 /public/js/index.js
parent1fb42bd276ff6806d733c2449a10840ae29903a9 (diff)
Fixed isInCode and code block textcomplete might not correct
Diffstat (limited to '')
-rw-r--r--public/js/index.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/public/js/index.js b/public/js/index.js
index f4b6904e..6a152a14 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -2191,7 +2191,7 @@ function checkCursorMenu() {
var isInCode = false;
function checkInCode() {
- isInCode = checkAbove() && checkBelow();
+ isInCode = checkAbove();
}
function checkAbove() {
@@ -2208,9 +2208,9 @@ function checkBelow() {
var cursor = editor.getCursor();
var count = editor.lineCount();
var text = [];
- for (var i = cursor.line + 1; i < count; i++) //not contain current line
+ for (var i = cursor.line + 1; i < count; i++) //contain current line
text.push(editor.getLine(i));
- text = text.join('\n') + '\n' + editor.getLine(cursor.line).slice(0, cursor.ch);
+ text = editor.getLine(cursor.line).slice(cursor.ch) + '\n' + text.join('\n');
//console.log(text);
return matchInCode(text);
}
@@ -2279,7 +2279,7 @@ $(editor.getInputField())
},
replace: function (lang) {
var ending = '';
- if (isInCode) {
+ if (!checkBelow()) {
ending = '\n\n```';
}
if (this.langs.indexOf(lang) !== -1)
@@ -2299,7 +2299,7 @@ $(editor.getInputField())
},
context: function (text) {
checkCursorMenu();
- return true;
+ return isInCode;
}
},
{ //header