Browse Source

fix: count sequential linebreaks correctly

tophf 4 năm trước cách đây
mục cha
commit
9ae02d6a67
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  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')
+);