Bug 1260042 - fix edge case with when auto-prettifying fails in debugger r=me
--- a/devtools/client/debugger/content/reducers/sources.js
+++ b/devtools/client/debugger/content/reducers/sources.js
@@ -62,18 +62,25 @@ function update(state = initialState, ac
case constants.TOGGLE_PRETTY_PRINT:
let s = state;
if (action.status === "error") {
s = mergeIn(state, ['sourcesText', action.source.actor], {
loading: false
});
- // If it errored, just display the source as it way before.
- emitChange('prettyprinted', s.sources[action.source.actor]);
+ // If it errored, just display the source as it was before, but
+ // only if there is existing text already. If auto-prettifying
+ // is on, the original text may still be coming in and we don't
+ // have it yet. If we try to set empty text we confuse the
+ // editor because it thinks it's already displaying the source's
+ // text and won't load the text when it actually comes in.
+ if(s.sourcesText[action.source.actor].text != null) {
+ emitChange('prettyprinted', s.sources[action.source.actor]);
+ }
}
else {
s = _updateText(state, action);
// Don't do this yet, the progress bar is still imperatively shown
// from the source view. We will fix in the next iteration.
// emitChange('source-text-loaded', s.sources[action.source.actor]);
if (action.status === 'done') {
--- a/devtools/client/shared/redux/non-react-subscriber.js
+++ b/devtools/client/shared/redux/non-react-subscriber.js
@@ -84,21 +84,16 @@ function makeStateBroadcaster(stillAlive
enqueuedChanges.push([name, payload]);
},
subscribeToStore: store => {
store.subscribe(() => {
if (stillAliveFunc()) {
enqueuedChanges.forEach(([name, payload]) => {
if (listeners[name]) {
- let payloadStr = payload;
- try {
- payloadStr = JSON.stringify(payload);
- }
- catch(e) {}
listeners[name].forEach(listener => {
listener(payload)
});
}
});
enqueuedChanges = [];
}
});