Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js b/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| index 6d2c45bb9d9775507401db5df26a8a08e98f0da5..15b2afda5cf951199f178a69434b8f9fca013bca 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| @@ -100,7 +100,42 @@ Sources.InplaceFormatterEditorAction = class { |
| start = formatterMapping.originalToFormatted(selection.startLine, selection.startColumn); |
| } |
| uiSourceCode.setWorkingCopy(formattedContent); |
| + this._formatDecorations(uiSourceCode, formatterMapping); |
| + |
| this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); |
| } |
| } |
| + |
| + /** |
| + * @param {!Workspace.UISourceCode} uiSourceCode |
| + * @param {!Sources.FormatterSourceMapping} sourceMapping |
| + */ |
| + _formatDecorations(uiSourceCode, sourceMapping) { |
| + var oldDecorations = new Map(uiSourceCode.getAllDecorations()); |
| + uiSourceCode.removeAllDecorations(); |
| + |
| + if (!oldDecorations.size) |
| + return; |
| + |
| + for (var decorationList of oldDecorations.entries()) { |
| + var type = decorationList[0]; |
| + var list = decorationList[1]; |
| + if (!list.size) |
|
caseq
2016/11/15 22:07:05
drop the check?
|
| + continue; |
| + |
| + for (var decoration of list.entries()) { |
| + var range = decoration[0]; |
| + var data = decoration[1]; |
| + var newRange = range; |
|
caseq
2016/11/15 22:07:05
This is rather confusing, we've not got one object
|
| + |
| + [newRange.startLine, newRange.startColumn] = sourceMapping.originalToFormatted( |
| + range.startLine, range.startColumn); |
| + |
| + [newRange.endLine, newRange.endColumn] = sourceMapping.originalToFormatted( |
| + range.endLine, range.endColumn); |
| + |
| + uiSourceCode.addDecoration(newRange, /** @type {string} */ (type), data); |
| + } |
| + } |
| + } |
| }; |