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..6a94bf2a3339577d4f4ba919ad06db3bf0b5aa6e 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,37 @@ 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 decorations = uiSourceCode.allDecorations(); |
| + if (!decorations.length) |
| + return; |
| + |
| + uiSourceCode.removeAllDecorations(); |
| + |
| + for (var decoration of decorations) { |
| + var range = decoration.range(); |
| + var startLocation = new Array(2); |
|
lushnikov
2016/11/17 22:50:43
drop these
|
| + var endLocation = new Array(2); |
| + |
| + startLocation = sourceMapping.originalToFormatted(range.startLine,range.startColumn); |
|
lushnikov
2016/11/17 22:50:43
why create arrays beforehand? just:
var startLoca
|
| + |
| + endLocation = sourceMapping.originalToFormatted(range.endLine,range.endColumn); |
|
lushnikov
2016/11/17 22:50:43
nit: space is required between function arguments
|
| + |
| + uiSourceCode.addDecoration( |
| + new Common.TextRange(startLocation[0], startLocation[1], |
| + endLocation[0], endLocation[1]), |
| + /** @type {string} */ (decoration.type()), |
| + decoration.data()); |
| + } |
| + } |
| }; |