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..d1d3f041d918eac295d764643f9cc6fe8f6a1937 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,38 @@ 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 formattedStartLine = sourceMapping.originalToFormatted(decoration.range().startLine, |
|
caseq
2016/11/17 22:13:19
nit: var range = decoration.range() for brevity.
|
| + decoration.range().startColumn)[0]; |
| + var formattedStartColumn = sourceMapping.originalToFormatted(decoration.range().startLine, |
|
caseq
2016/11/17 22:13:19
why are we calling it twice with the same argument
|
| + decoration.range().startColumn)[1]; |
| + |
| + var formattedEndLine = sourceMapping.originalToFormatted(decoration.range().endLine, |
| + decoration.range().endColumn)[0]; |
|
caseq
2016/11/17 22:13:19
let's just indent +4 spaces from the start of prev
|
| + var formattedEndColumn = sourceMapping.originalToFormatted(decoration.range().endLine, |
| + decoration.range().endColumn)[1]; |
| + |
| + uiSourceCode.addDecoration(new Common.TextRange(formattedStartLine, formattedStartColumn, |
| + formattedEndLine, formattedEndColumn), |
| + /** @type {string} */ (decoration.type()), |
| + decoration.data()); |
| + } |
| + } |
| }; |