Skip to content

Commit

Permalink
fix termsel.js coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
poying committed Aug 1, 2015
1 parent b627485 commit 380cefb
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/termsel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand All @@ -129,7 +130,7 @@ TermSel.prototype={
}
}
if(startCol < endCol) // has visible selection region
var hasSelection = true;
hasSelection = true;
}
if(!hasSelection)
this.cancelSel(true);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -313,6 +314,6 @@ TermSel.prototype={
}
return this.view.decoder(ret);
}
}
};

module.exports = TermSel;

0 comments on commit 380cefb

Please sign in to comment.