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 b703d279eb5cec8055e0a3d25cdda210bc4dd2c6..76cdd1f73798f7c57fec35080c9e34b64ace027f 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/sources/InplaceFormatterEditorAction.js |
| @@ -99,7 +99,36 @@ 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) { |
| + if (!uiSourceCode.allDecorations) |
| + return; |
| + |
| + var oldDecorations = new Map(uiSourceCode.allDecorations); |
| + uiSourceCode.removeAllDecorations(); |
| + |
| + for (var decorationList of oldDecorations.entries()) { |
| + var type = decorationList[0]; |
| + var list = decorationList[1]; |
| + |
| + for (var decoration of list) { |
| + var range = decoration.range(); |
| + |
| + [range.startLine, range.startColumn] = sourceMapping.originalToFormatted(range.startLine, range.startColumn); |
|
lushnikov
2016/11/16 22:53:54
1. let's not mutate range
2. let's not use array d
|
| + |
| + [range.endLine, range.endColumn] = sourceMapping.originalToFormatted(range.endLine, range.endColumn); |
| + |
| + uiSourceCode.addDecoration(range, /** @type {string} */ (type), decoration.data()); |
| + } |
| + } |
| + } |
| }; |