Skip to content

Commit

Permalink
fix: global jump does not switch tabs (#139)
Browse files Browse the repository at this point in the history
This PR fixes the issue on global mark. Jumping to a global mark did not
switch tabs.
  • Loading branch information
ueokande authored Apr 27, 2023
1 parent 6730894 commit e8a232b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/background/usecases/MarkJumpUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default class MarkJumpUseCase {
const smooth = (await this.propertySettings.getProperty(
"smoothscroll"
)) as boolean;

try {
await this.contentMessageClient.scrollTo(
mark.tabId,
Expand All @@ -51,7 +52,7 @@ export default class MarkJumpUseCase {
mark.y,
smooth
);
await chrome.tabs.update(tabId, { active: true });
await chrome.tabs.update(mark.tabId, { active: true });
return;
} catch (e) {
const tab = await chrome.tabs.create({ url: mark.url });
Expand Down
6 changes: 3 additions & 3 deletions test/background/usecases/MarkJumpUseCase.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("MarkJumpUseCase", () => {
const mockGetGlobalMark = jest
.spyOn(markRepository, "getGlobalMark")
.mockResolvedValue({
tabId: 100,
tabId: 101,
url: "https://example.com/",
x: 10,
y: 20,
Expand All @@ -53,8 +53,8 @@ describe("MarkJumpUseCase", () => {
await sut.jumpToMark("A");

expect(mockGetGlobalMark).toHaveBeenCalledWith("A");
expect(mockScrollTo).toHaveBeenCalledWith(100, 0, 10, 20, true);
expect(mockTabsUpdate).toHaveBeenCalledWith(100, { active: true });
expect(mockScrollTo).toHaveBeenCalledWith(101, 0, 10, 20, true);
expect(mockTabsUpdate).toHaveBeenCalledWith(101, { active: true });
});

it("reopens tabs when the tab of the global mark is gone", async () => {
Expand Down

0 comments on commit e8a232b

Please # to comment.