bundles/org.eclipse.orion.client.ui/web/orion/compare/diffParser.js
function(hunkRangeNo ){
			var lastToken = " "; //$NON-NLS-0$
			var startNo = this._hunkRanges[hunkRangeNo][0] + 1;
			var endNo = (hunkRangeNo === (this._hunkRanges.length - 1) ) ? this._diffContents.length : this._hunkRanges[hunkRangeNo+1][0];

			var oCursor = 0;
			var nCursor = 0;
			var oBlkStart = this._hunkRanges[hunkRangeNo][1];
			var nBlkStart = this._hunkRanges[hunkRangeNo][3];
			var lastPlusPos = startNo;
			var lastMinusPos = startNo;
			for (var i = startNo ; i< endNo ; i++){
				if( 0 === this._diffContents[i].length){
					continue;
				}
				var curToken = this._diffContents[i][0];
				if(curToken === "\\"){ //$NON-NLS-0$
					if( NO_NEW_LINE === this._diffContents[i].substring(0 , this._diffContents[i].length-1) ||
						NO_NEW_LINE === this._diffContents[i]){
						if(lastToken === "-"){ //$NON-NLS-0$
							this._oNewLineAtEnd = false;
						} else if(lastToken === " "){ //$NON-NLS-0$
							this._nNewLineAtEnd = false;
							this._oNewLineAtEnd = false;
						} else {
							this._nNewLineAtEnd = false;
						}
						if(i > startNo && this._diffContents[i-1][this._diffContents[i-1].length-1] === "\r"){ //$NON-NLS-0$
							this._diffContents[i-1] = this._diffContents[i-1].substring(0 , this._diffContents[i-1].length-1);
						}
						continue;
					}
				}
				switch(curToken){
				case "-": //$NON-NLS-0$
				case "+": //$NON-NLS-0$
				case " ": //$NON-NLS-0$
					break;
				default:
					continue;
				}

				if(lastToken !== curToken){
					if(curToken === "+"){ //$NON-NLS-0$
						lastPlusPos = i;
					}
					if(curToken === "-"){ //$NON-NLS-0$
						lastMinusPos = i;
					}
					switch(lastToken){
					case " ": //$NON-NLS-0$
						oBlkStart = this._hunkRanges[hunkRangeNo][1] + oCursor;
						nBlkStart = this._hunkRanges[hunkRangeNo][3] + nCursor;
						break;
					case "-": //$NON-NLS-0$
						this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos);
						break;
					case "+": //$NON-NLS-0$
						this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos);
						break;
					default:
					}
					lastToken = curToken;
				}

				switch(curToken){
				case "-": //$NON-NLS-0$
					oCursor++;
					break;
				case "+": //$NON-NLS-0$
					nCursor++;
					break;
				case " ": //$NON-NLS-0$
					oCursor++;
					nCursor++;
					break;
				}
			}
			switch(lastToken){
			case "-": //$NON-NLS-0$
				this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos);
				break;
			case "+": //$NON-NLS-0$
				this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos);
				break;
			}
		}
function(hunkRangeNo ){
			var lastToken = " "; //$NON-NLS-0$
			var startNo = this._hunkRanges[hunkRangeNo][0] + 1;
			var endNo = (hunkRangeNo === (this._hunkRanges.length - 1) ) ? this._diffContents.length : this._hunkRanges[hunkRangeNo+1][0];

			var oCursor = 0;
			var nCursor = 0;
			var oBlkStart = this._hunkRanges[hunkRangeNo][1];
			var nBlkStart = this._hunkRanges[hunkRangeNo][3];
			var lastPlusPos = startNo;
			var lastMinusPos = startNo;
			for (var i = startNo ; i< endNo ; i++){
				if( 0 === this._diffContents[i].length){
					continue;
				}
				var curToken = this._diffContents[i][0];
				if(curToken === "\\"){ //$NON-NLS-0$
					if( NO_NEW_LINE === this._diffContents[i].substring(0 , this._diffContents[i].length-1) ||
						NO_NEW_LINE === this._diffContents[i]){
						if(lastToken === "-"){ //$NON-NLS-0$
							this._oNewLineAtEnd = false;
						} else if(lastToken === " "){ //$NON-NLS-0$
							this._nNewLineAtEnd = false;
							this._oNewLineAtEnd = false;
						} else {
							this._nNewLineAtEnd = false;
						}
						if(i > startNo && this._diffContents[i-1][this._diffContents[i-1].length-1] === "\r"){ //$NON-NLS-0$
							this._diffContents[i-1] = this._diffContents[i-1].substring(0 , this._diffContents[i-1].length-1);
						}
						continue;
					}
				}
				switch(curToken){
				case "-": //$NON-NLS-0$
				case "+": //$NON-NLS-0$
				case " ": //$NON-NLS-0$
					break;
				default:
					continue;
				}

				if(lastToken !== curToken){
					if(curToken === "+"){ //$NON-NLS-0$
						lastPlusPos = i;
					}
					if(curToken === "-"){ //$NON-NLS-0$
						lastMinusPos = i;
					}
					switch(lastToken){
					case " ": //$NON-NLS-0$
						oBlkStart = this._hunkRanges[hunkRangeNo][1] + oCursor;
						nBlkStart = this._hunkRanges[hunkRangeNo][3] + nCursor;
						break;
					case "-": //$NON-NLS-0$
						this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos);
						break;
					case "+": //$NON-NLS-0$
						this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos);
						break;
					default:
					}
					lastToken = curToken;
				}

				switch(curToken){
				case "-": //$NON-NLS-0$
					oCursor++;
					break;
				case "+": //$NON-NLS-0$
					nCursor++;
					break;
				case " ": //$NON-NLS-0$
					oCursor++;
					nCursor++;
					break;
				}
			}
			switch(lastToken){
			case "-": //$NON-NLS-0$
				this._createMinusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][1] + oCursor - oBlkStart, lastMinusPos);
				break;
			case "+": //$NON-NLS-0$
				this._createPlusBlock(oBlkStart , nBlkStart ,this._hunkRanges[hunkRangeNo][3] + nCursor - nBlkStart , lastPlusPos);
				break;
			}
		}
function ( hunkRangeNo ) { var lastToken = " " ; //$NON-NLS-0$ var startNo = this . _hunkRanges [ hunkRangeNo ] [ 0 ] + 1 ; var endNo = ( hunkRangeNo === ( this . _hunkRanges . length - 1 ) ) ? this . _diffContents . length : this . _hunkRanges [ hunkRangeNo + 1 ] [ 0 ] ; var oCursor = 0 ; var nCursor = 0 ; var oBlkStart = this . _hunkRanges [ hunkRangeNo ] [ 1 ] ; var nBlkStart = this . _hunkRanges [ hunkRangeNo ] [ 3 ] ; var lastPlusPos = startNo ; var lastMinusPos = startNo ; for ( var i = startNo ; i < endNo ; i ++ ) { if ( 0 === this . _diffContents [ i ] . length ) { continue ; } var curToken = this . _diffContents [ i ] [ 0 ] ; if ( curToken === "\\" ) { //$NON-NLS-0$ if ( NO_NEW_LINE === this . _diffContents [ i ] . substring ( 0 , this . _diffContents [ i ] . length - 1 ) || NO_NEW_LINE === this . _diffContents [ i ] ) { if ( lastToken === "-" ) { //$NON-NLS-0$ this . _oNewLineAtEnd = false ; } else if ( lastToken === " " ) { //$NON-NLS-0$ this . _nNewLineAtEnd = false ; this . _oNewLineAtEnd = false ; } else { this . _nNewLineAtEnd = false ; } if ( i > startNo && this . _diffContents [ i - 1 ] [ this . _diffContents [ i - 1 ] . length - 1 ] === "\r" ) { //$NON-NLS-0$ this . _diffContents [ i - 1 ] = this . _diffContents [ i - 1 ] . substring ( 0 , this . _diffContents [ i - 1 ] . length - 1 ) ; } continue ; } } switch ( curToken ) { case "-" : //$NON-NLS-0$ case "+" : //$NON-NLS-0$ case " " : //$NON-NLS-0$ break ; default : continue ; } if ( lastToken !== curToken ) { if ( curToken === "+" ) { //$NON-NLS-0$ lastPlusPos = i ; } if ( curToken === "-" ) { //$NON-NLS-0$ lastMinusPos = i ; } switch ( lastToken ) { case " " : //$NON-NLS-0$ oBlkStart = this . _hunkRanges [ hunkRangeNo ] [ 1 ] + oCursor ; nBlkStart = this . _hunkRanges [ hunkRangeNo ] [ 3 ] + nCursor ; break ; case "-" : //$NON-NLS-0$ this . _createMinusBlock ( oBlkStart , nBlkStart , this . _hunkRanges [ hunkRangeNo ] [ 1 ] + oCursor - oBlkStart , lastMinusPos ) ; break ; case "+" : //$NON-NLS-0$ this . _createPlusBlock ( oBlkStart , nBlkStart , this . _hunkRanges [ hunkRangeNo ] [ 3 ] + nCursor - nBlkStart , lastPlusPos ) ; break ; default : } lastToken = curToken ; } switch ( curToken ) { case "-" : //$NON-NLS-0$ oCursor ++ ; break ; case "+" : //$NON-NLS-0$ nCursor ++ ; break ; case " " : //$NON-NLS-0$ oCursor ++ ; nCursor ++ ; break ; } } switch ( lastToken ) { case "-" : //$NON-NLS-0$ this . _createMinusBlock ( oBlkStart , nBlkStart , this . _hunkRanges [ hunkRangeNo ] [ 1 ] + oCursor - oBlkStart , lastMinusPos ) ; break ; case "+" : //$NON-NLS-0$ this . _createPlusBlock ( oBlkStart , nBlkStart , this . _hunkRanges [ hunkRangeNo ] [ 3 ] + nCursor - nBlkStart , lastPlusPos ) ; break ; } }
read line by line in a hunk range
read line by line in a hunk range