Bug 1585407 - setPendingSelectedLocation loses line/column r=jlast

Differential Revision: https://phabricator.services.mozilla.com/D47802

--HG--
extra : moz-landing-system : lando
This commit is contained in:
wartmanm 2019-10-04 00:25:20 +00:00
parent 48ca0e736f
commit db64512ef6
3 changed files with 9 additions and 6 deletions

View File

@ -58,12 +58,13 @@ export const setSelectedLocation = (
export const setPendingSelectedLocation = (
cx: Context,
url: string,
options: Object
options?: PartialPosition
) => ({
type: "SET_PENDING_SELECTED_LOCATION",
cx,
url: url,
line: options.location ? options.location.line : null,
url,
line: options ? options.line : null,
column: options ? options.column : null,
});
export const clearSelectedLocation = (cx: Context) => ({
@ -85,7 +86,7 @@ export const clearSelectedLocation = (cx: Context) => ({
export function selectSourceURL(
cx: Context,
url: string,
options: PartialPosition = {}
options?: PartialPosition
) {
return async ({ dispatch, getState, sourceMaps }: ThunkArgs) => {
const source = getSourceByURL(getState(), url);

View File

@ -190,14 +190,15 @@ describe("sources", () => {
it("sets and clears pending selected location correctly", () => {
const { dispatch, getState, cx } = createStore(mockCommandClient);
const url = "testURL";
const options = { location: { line: "testLine" } };
const options = { line: "testLine", column: "testColumn" };
// set value
dispatch(actions.setPendingSelectedLocation(cx, url, options));
const setResult = getState().sources.pendingSelectedLocation;
expect(setResult).toEqual({
url,
line: options.location.line,
line: options.line,
column: options.column,
});
// clear value

View File

@ -203,6 +203,7 @@ function update(
location = {
url: action.url,
line: action.line,
column: action.column,
};
prefs.pendingSelectedLocation = location;