Skip to content

Commit

Permalink
LESS: Fixes SourceMap path in CSS.
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Dec 31, 2013
1 parent d233a60 commit 5160d90
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions EditorExtensions/Margin/LessMargin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override async void StartCompiler(string source)

string lessFilePath = Document.FilePath;

string cssFilename = GetCompiledFileName(lessFilePath, ".css", CompileEnabled ? CompileToLocation : null);// Document.FilePath.Replace(".less", ".css");
string cssFilename = GetCompiledFileName(lessFilePath, ".css", CompileEnabled ? CompileToLocation : null);

if (IsFirstRun && File.Exists(cssFilename))
{
Expand Down Expand Up @@ -103,7 +103,7 @@ protected override string UpdateLessSourceMapUrls(string content, string sourceF

WriteFile(updatedFileContent, sourceMapFilename, true, false);

return UpdateSourceLinkInCssComment(content, FileHelpers.RelativePath(sourceMapFilename, compiledFileName));
return UpdateSourceLinkInCssComment(content, FileHelpers.RelativePath(compiledFileName, sourceMapFilename));

This comment has been minimized.

Copy link
@SLaks

SLaks Dec 31, 2013

I believe that's wrong.

This comment has been minimized.

Copy link
@am11

am11 Dec 31, 2013

Author Owner

@SLaks no; it will give path to .map file relative to .css.

This comment has been minimized.

Copy link
@SLaks

SLaks Dec 31, 2013

The first argument to RelativePath() is the absolute path to resolve.

public static string RelativePath(string absolutePath, string relativeTo)

This comment has been minimized.

Copy link
@am11

am11 Dec 31, 2013

Author Owner

The other way around gives link to .css file. Test it.

This comment has been minimized.

Copy link
@SLaks

SLaks Dec 31, 2013

You're right.

Those parameters are confusingly misnamed & should be corrected.

This comment has been minimized.

Copy link
@am11

am11 Dec 31, 2013

Author Owner

Yes! We can change the signature to: GetRelativePathTo(string fromPath, string toPath);. This is inspired by PathRelativePathTo() C++ function in shlwapi.dll. (second and fourth parameter)

This comment has been minimized.

Copy link
@SLaks

SLaks Jan 1, 2014

Alternatively, we can replace it entirely with http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.shell.packageutilities.makerelative.aspx (which unfortunately also has poor names)

This comment has been minimized.

Copy link
@am11

am11 Jan 1, 2014

Author Owner

Separately, in this scenario (for now) we don't really need RelativePath (just Path.GetFileName(sourceMapFilename)).

I put it there for future consideration; if we give user an option to save SourceMap files at different location.

Less Compiler supports saving corresponding .map, .css and .less all at different places. While CoffeeSCript doesn't support that yet (atm, it has issue when saving .js file at separate location jashkenas/coffeescript#3296).

Once SourceMap from various compilers get this ability consistent, we will provide that option in settings.

}

private static string GetUpdatedSourceMapFileContent(string cssFileName, string sourceMapFilename)
Expand Down

0 comments on commit 5160d90

Please sign in to comment.