Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
v2.7.1 HOTFIX
  • Loading branch information
matthew-dean committed May 9, 2016
1 parent 36edeaa commit d3e1531
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 47 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,9 @@
# 2.7.1 HOTFIX

2016-05-09

- Revert commit 470af20 (source map performance) which broke source maps

# 2.7.0

2016-05-07
Expand Down
72 changes: 32 additions & 40 deletions dist/less.js
@@ -1,5 +1,5 @@
/*!
* Less - Leaner CSS v2.7.0
* Less - Leaner CSS v2.7.1
* http://lesscss.org
*
* Copyright (c) 2009-2016, Alexis Sellier <self@cloudhead.net>
Expand Down Expand Up @@ -2485,7 +2485,7 @@ module.exports = function(environment, fileManagers) {
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;

var less = {
version: [2, 7, 0],
version: [2, 7, 1],
data: require('./data'),
tree: require('./tree'),
Environment: (Environment = require("./environment/environment")),
Expand Down Expand Up @@ -4454,10 +4454,10 @@ var Parser = function Parser(context, imports, fileInfo) {
},

media: function () {
var features, rules, media, debugInfo;
var features, rules, media, debugInfo, index = parserInput.i;

if (context.dumpLineNumbers) {
debugInfo = getDebugInfo(parserInput.i);
debugInfo = getDebugInfo(index);
}

parserInput.save();
Expand All @@ -4473,7 +4473,7 @@ var Parser = function Parser(context, imports, fileInfo) {

parserInput.forget();

media = new(tree.Media)(rules, features, parserInput.i, fileInfo);
media = new(tree.Media)(rules, features, index, fileInfo);
if (context.dumpLineNumbers) {
media.debugInfo = debugInfo;
}
Expand Down Expand Up @@ -5253,39 +5253,11 @@ module.exports = function (SourceMapOutput, environment) {
},{}],43:[function(require,module,exports){
module.exports = function (environment) {

/**
* @param source The code
* @param ignoredCharsCount Number of characters at the start of the file to ignore.
* @constructor
*/
var FileInfo = function (source, ignoredCharsCount) {
this.ignoredCharsCount = ignoredCharsCount;
this.source = source.slice(ignoredCharsCount);
this.sourceLines = this.source.split('\n');
};

/** Translate absolute source offset to line/column offset. */
FileInfo.prototype.getLocation = function (index) {
index = Math.max(0, index - this.ignoredCharsCount);
var line = 0;
for (; line < this.sourceLines.length && index >= this.sourceLines[line].length + 1; line++) {
index -= this.sourceLines[line].length + 1; // +1 for the '\n' character
}
return {line: line + 1, column: index};
};

var SourceMapOutput = function (options) {
this._css = [];
this._rootNode = options.rootNode;

this._contentsInfoMap = {};
for (var key in options.contentsMap) {
if (options.contentsMap.hasOwnProperty(key)) {
this._contentsInfoMap[key] = new FileInfo(
options.contentsMap[key], options.contentsIgnoredCharsMap[key] || 0);
}
}

this._contentsMap = options.contentsMap;
this._contentsIgnoredCharsMap = options.contentsIgnoredCharsMap;
if (options.sourceMapFilename) {
this._sourceMapFilename = options.sourceMapFilename.replace(/\\/g, '/');
}
Expand Down Expand Up @@ -5329,22 +5301,39 @@ module.exports = function (environment) {
}

var lines,
sourceLines,
columns,
sourceColumns,
i;

if (fileInfo) {
var inputSource = this._contentsMap[fileInfo.filename];

// remove vars/banner added to the top of the file
if (this._contentsIgnoredCharsMap[fileInfo.filename]) {
// adjust the index
index -= this._contentsIgnoredCharsMap[fileInfo.filename];
if (index < 0) { index = 0; }
// adjust the source
inputSource = inputSource.slice(this._contentsIgnoredCharsMap[fileInfo.filename]);
}
inputSource = inputSource.substring(0, index);
sourceLines = inputSource.split("\n");
sourceColumns = sourceLines[sourceLines.length - 1];
}

lines = chunk.split("\n");
columns = lines[lines.length - 1];

if (fileInfo) {
var location = this._contentsInfoMap[fileInfo.filename].getLocation(index);
if (!mapLines) {
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + 1, column: this._column},
original: location,
original: { line: sourceLines.length, column: sourceColumns.length},
source: this.normalizeFilename(fileInfo.filename)});
} else {
for (i = 0; i < lines.length; i++) {
this._sourceMapGenerator.addMapping({ generated: { line: this._lineNumber + i + 1, column: i === 0 ? this._column : 0},
original: { line: location.line + i, column: i === 0 ? location.column : 0},
original: { line: sourceLines.length + i, column: i === 0 ? sourceColumns.length : 0},
source: this.normalizeFilename(fileInfo.filename)});
}
}
Expand All @@ -5369,8 +5358,11 @@ module.exports = function (environment) {

if (this._outputSourceFiles) {
for (var filename in this._contentsMap) {
if (this._contentsInfoMap.hasOwnProperty(filename)) {
var source = this._contentsInfoMap[filename].source;
if (this._contentsMap.hasOwnProperty(filename)) {
var source = this._contentsMap[filename];
if (this._contentsIgnoredCharsMap[filename]) {
source = source.slice(this._contentsIgnoredCharsMap[filename]);
}
this._sourceMapGenerator.setSourceContent(this.normalizeFilename(filename), source);
}
}
Expand Down
10 changes: 5 additions & 5 deletions dist/less.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/less/index.js
Expand Up @@ -2,7 +2,7 @@ module.exports = function(environment, fileManagers) {
var SourceMapOutput, SourceMapBuilder, ParseTree, ImportManager, Environment;

var less = {
version: [2, 7, 0],
version: [2, 7, 1],
data: require('./data'),
tree: require('./tree'),
Environment: (Environment = require("./environment/environment")),
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "less",
"version": "2.7.0",
"version": "2.7.1",
"description": "Leaner CSS",
"homepage": "http://lesscss.org",
"author": {
Expand Down

0 comments on commit d3e1531

Please sign in to comment.