Skip to content
This repository has been archived by the owner on Aug 14, 2022. It is now read-only.

Open with pdf-view doesn't open in background #413

Closed
nisargjhaveri opened this issue Sep 11, 2017 · 8 comments
Closed

Open with pdf-view doesn't open in background #413

nisargjhaveri opened this issue Sep 11, 2017 · 8 comments
Assignees

Comments

@nisargjhaveri
Copy link

I have "Open Result in Background" option ticked and I've selected "Opener" to be pdf-view and "Pdf View Split Direction" to right. I also have "Build in save" and "Open Result after Successful Build" ticked.

It correctly builds the PDF on save and opens it in the right panel, but the focus now is on the PDF and not on the editor pane. Which means I have to manually focus the edit pane every time I press ctrl+s.

I believe "Open Result in Background" means that this should not happen and after opening the PDF in right pane, the focus should be retained at the editor pane.

latex version installed is 0.46.0

$ atom --version
Atom    : 1.19.3
Electron: 1.6.9
Chrome  : 56.0.2924.87
Node    : 7.4.0
@yitzchak
Copy link
Collaborator

Thanks for your issue report! We'll look into it.

@nisargjhaveri
Copy link
Author

I think this is causing the problem. I don't know if it is required any longer or for backward compatibility, but removing that and adding activatePane: false to options for atom.workspace.open seems to work for me.

const texPane = atom.workspace.paneForURI(texPath)
// This prevents splitting the right pane multiple times
if (texPane) {
texPane.activate()
}

Hope this helps! :)

@yitzchak
Copy link
Collaborator

@nisargjhaveri Thanks doing some research. The texPane.activate is needed to ensure the right split, especially when using multiple jobs. I'll investigate and see if I can come up with a combination of settings that work for both cases.

@yitzchak yitzchak self-assigned this Sep 11, 2017
@nisargjhaveri
Copy link
Author

One more observation. Just adding activatePane: false to options for atom.workspace.open seems to work, without removing texPane.activate also. Only problem is that, if the pane is not already open, then the editor loses focus.

I got to playing with again because I noticed some other problem. It doesn't forward sync properly. It just goes to the page in PDF and doesn't scroll to the actual content location. This probably is unrelated, but just pointing out just in case.

@nisargjhaveri
Copy link
Author

I was looking more into it.

From what I understand markdown-preview does the following.
It stores the previously active pane with previousActivePane = atom.workspace.getActivePane() and then after opening new pane, it does previousActivePane.activate(). See, https://github.com/atom/markdown-preview/blob/master/lib/main.coffee#L82-L89

Adding the first line after line 8 and second line at line 23 seems to work for me nice, for both the case, if the pane is already open or if it is not. I don't think I know enough cases to test it and send a PR.

@yitzchak
Copy link
Collaborator

@nisargjhaveri I've integrated your suggestions into #416. So far it doesn't look like it breaks any existing functionality.

@thomasjo
Copy link
Owner

@nisargjhaveri Thanks for all your hard work on this issue! We really appreciate the help 🙇‍♂️

@nisargjhaveri
Copy link
Author

No problem! Happy it got resolved! :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants