Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[Scopes] expanded properties are not updated while stepping #2509

Merged
merged 11 commits into from Apr 5, 2017
2 changes: 1 addition & 1 deletion src/components/Editor/SearchBar.js
Expand Up @@ -32,7 +32,7 @@ const ImPropTypes = require("react-immutable-proptypes");

import type {
FormattedSymbolDeclaration,
SymbolDeclaration,
SymbolDeclaration
} from "../../utils/parser/utils";

function getShortcuts() {
Expand Down
16 changes: 16 additions & 0 deletions src/utils/object-inspector.js
Expand Up @@ -181,6 +181,22 @@ function getChildren(
// node would be a new instance every render.
const key = item.path;
if (actors && actors[key]) {
if (item.contents.value && item.contents.value.preview) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this code to an updateActor helper function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem 🙂

const properties = item.contents.value.preview.ownProperties;
for (let pKey in properties) {
if (properties.hasOwnProperty(pKey)) {
const cacheObject = actors[key].filter(a => a.name == pKey)[0];
const cacheObjectIndex = actors[key].findIndex(a => a.name == pKey);
// Assign new values to the cache actor if it goes stale
if (
cacheObject && cacheObject.contents.value != properties[pKey].value
) {
actors[key][cacheObjectIndex].contents = properties[pKey];
}
}
}
}

return actors[key];
}

Expand Down
62 changes: 61 additions & 1 deletion src/utils/tests/object-inspector.js
Expand Up @@ -3,7 +3,8 @@ const expect = require("expect.js");
const {
makeNodesForProperties,
isPromise,
getPromiseProperties
getPromiseProperties,
getChildren
} = require("../object-inspector");

const objProperties = {
Expand Down Expand Up @@ -221,4 +222,63 @@ describe("promises", () => {
const node = getPromiseProperties(promise);
expect(node.contents.value.type).to.eql("3");
});

it("update actors when necessary", () => {
const item = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove some of the data from this fixture so that it is much smaller. for instance, do we need the entire value? Can we remove preview's contents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please check my new commit :)

contents: {
enumerable: true,
configurable: false,
value: {
frozen: false,
ownPropertyLength: 0,
preview: {
kind: "Object",
ownProperties: {
color: {
configurable: true,
enumerable: true,
value: "red",
writable: true
}
},
ownPropertiesLength: 1,
safeGetterValues: {}
},
actor: "server2.conn2.child1/pausedobj36",
promiseState: {
state: "rejected",
reason: {
type: "3"
},
creationTimestamp: 1486584316133.3994,
timeToSettle: 0.001713000237941742
},
class: "Promise",
type: "object",
extensible: true,
sealed: false
},
writable: true
},
name: "car",
path: "Block/car"
};

let actors = new Object();
actors["Block/car"] = [
{
contents: {
configureable: true,
enumerable: true,
value: "white",
writable: true
},
name: "color",
path: "Block/car/color"
}
];

const children = getChildren({ function() {}, actors, item });
expect(children[0].contents.value).to.eql("red");
});
});