Skip to content

Commit d963582

Browse files
author
Wes Cossick
committed
Fix line and word count on init (sparksuite#299)
1 parent 69bff3e commit d963582

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/js/simplemde.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ function extend(target) {
10521052

10531053
/* The right word count in respect for CJK. */
10541054
function wordCount(data) {
1055-
var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
1055+
var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
10561056
var m = data.match(pattern);
10571057
var count = 0;
10581058
if(m === null) return count;
@@ -1517,8 +1517,8 @@ SimpleMDE.prototype.render = function(el) {
15171517
this.gui.sideBySide = this.createSideBySide();
15181518

15191519
this._rendered = this.element;
1520-
1521-
1520+
1521+
15221522
// Fixes CodeMirror bug (#344)
15231523
var temp_cm = this.codemirror;
15241524
setTimeout(function() {
@@ -1782,14 +1782,14 @@ SimpleMDE.prototype.createStatusbar = function(status) {
17821782

17831783
if(name === "words") {
17841784
defaultValue = function(el) {
1785-
el.innerHTML = "0";
1785+
el.innerHTML = wordCount(cm.getValue());
17861786
};
17871787
onUpdate = function(el) {
17881788
el.innerHTML = wordCount(cm.getValue());
17891789
};
17901790
} else if(name === "lines") {
17911791
defaultValue = function(el) {
1792-
el.innerHTML = "0";
1792+
el.innerHTML = cm.lineCount();
17931793
};
17941794
onUpdate = function(el) {
17951795
el.innerHTML = cm.lineCount();

0 commit comments

Comments
 (0)