Browse Source

fix: count sequential linebreaks correctly

tophf 4 years ago
parent
commit
9ae02d6a67
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/common/ui/style/index.js

+ 5 - 1
src/common/ui/style/index.js

@@ -77,4 +77,8 @@ options.hook((changes) => {
 });
 
 Vue.prototype.i18n = i18n;
-Vue.prototype.CalcRows = val => val && (val.match(/\n.|$/g).length + 1);
+/** @returns {?number} Number of lines + 1 if the last line is not empty */
+Vue.prototype.CalcRows = val => val && (
+  val.match(/$/gm).length
+  + !val.endsWith('\n')
+);