From 380cefba2a874275c432d13c508228bfe923503c Mon Sep 17 00:00:00 2001 From: Po-Ying Chen Date: Sat, 1 Aug 2015 19:05:46 +0800 Subject: [PATCH] fix termsel.js coding style --- lib/termsel.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/termsel.js b/lib/termsel.js index 53c0d51..8eafde1 100644 --- a/lib/termsel.js +++ b/lib/termsel.js @@ -40,7 +40,7 @@ TermSel.prototype={ selUpdate: function(col, row) { this.realEndCol = col; this.realEndRow = row; - var col1, col2, row1, row2, col, row; + var col1, col2, row1, row2; // swap start and end points to kept them in correct order if(this.realEndRow == this.realStartRow) { // only one line is selected @@ -110,10 +110,11 @@ TermSel.prototype={ selTrim: function() { var buf = this.view.buf; + var hasSelection = false; if(this.blockMode) { for(var row=this.startRow; row<=this.endRow; ++row) { - var line = buf.lines[row]; + let line = buf.lines[row]; var startCol = this.startCol; if(startCol > 0) { if(line[startCol-1].isLeadByte) { @@ -129,7 +130,7 @@ TermSel.prototype={ } } if(startCol < endCol) // has visible selection region - var hasSelection = true; + hasSelection = true; } if(!hasSelection) this.cancelSel(true); @@ -153,8 +154,8 @@ TermSel.prototype={ // fit the real selection on the screen if(this.endCol == buf.cols) this.endCol--; - var col = this.endCol; - var line = buf.lines[this.endRow]; + col = this.endCol; + line = buf.lines[this.endRow]; if(!line[col].isSelected) { if (!line[col].isLeadByte && line[col-1].isLeadByte) line[col].isSelected = true; @@ -258,15 +259,15 @@ TermSel.prototype={ var ret = ''; var tmp = ''; if(this.startRow == this.endRow) { // only one line is selected - var line = lines[this.startRow]; + let line = lines[this.startRow]; tmp = ''; for(col = this.startCol; col <= endCol; ++col) tmp += line[col].ch; ret += strStrip(tmp); } else { - var cols = buf.cols; - var line = lines[this.startRow]; + let cols = buf.cols; + let line = lines[this.startRow]; for(col = this.startCol; col < cols; ++col) tmp += line[col].ch; ret += strStrip(tmp); @@ -299,7 +300,7 @@ TermSel.prototype={ var ret = ''; var tmp = ''; for(row = this.startRow; row <= this.endRow; ++row) { - var line = lines[row]; + let line = lines[row]; tmp = ''; for(col = startCol; col < endCol; ++col) tmp += line[col].ch; @@ -313,6 +314,6 @@ TermSel.prototype={ } return this.view.decoder(ret); } -} +}; module.exports = TermSel;