mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-10 13:44:39 +08:00
Fix Pretty-Print Infobar not working
This CL fixes the Pretty-Print Infobar not formatting the source file when the Pretty-Print button is pressed. The bug was caused by a subtle change to the button delegate when it was updated to support TypeScript causing it to no longer invoke the format function. The CL slightly modifies the ScriptFormatterEditorAction to have button a event handler to absorb the unused 'event' argument, so the Infobar does not need to pass one to toggleFormatScriptSource. Bug: 1159531 Change-Id: I8e1876e8ce0ebc1e498e81a619a905a007cabdf5 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2596121 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Brian Cui <brcui@microsoft.com>
This commit is contained in:
@@ -1781,7 +1781,7 @@ export class DebuggerPlugin extends Plugin {
|
||||
if (!editorAction.isCurrentUISourceCodeFormatable()) {
|
||||
return;
|
||||
}
|
||||
formatterCallback = () => editorAction.toggleFormatScriptSource.bind(editorAction);
|
||||
formatterCallback = editorAction.toggleFormatScriptSource.bind(editorAction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export class ScriptFormatterEditorAction {
|
||||
});
|
||||
|
||||
this._button = new UI.Toolbar.ToolbarButton(Common.UIString.UIString('Pretty print'), 'largeicon-pretty-print');
|
||||
this._button.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, this.toggleFormatScriptSource, this);
|
||||
this._button.addEventListener(UI.Toolbar.ToolbarButton.Events.Click, this._onFormatScriptButtonClicked, this);
|
||||
this._updateButton(sourcesView.currentUISourceCode());
|
||||
|
||||
return this._button;
|
||||
@@ -125,7 +125,11 @@ export class ScriptFormatterEditorAction {
|
||||
/**
|
||||
* @param {!Common.EventTarget.EventTargetEvent} event
|
||||
*/
|
||||
toggleFormatScriptSource(event) {
|
||||
_onFormatScriptButtonClicked(event) {
|
||||
this.toggleFormatScriptSource();
|
||||
}
|
||||
|
||||
toggleFormatScriptSource() {
|
||||
const uiSourceCode = this._sourcesView.currentUISourceCode();
|
||||
if (!uiSourceCode || !this._isFormatableScript(uiSourceCode)) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user