thomasjo / atom-latex

Compile LaTeX or knitr documents from within Atom
https://atom.io/packages/latex
MIT License
223 stars 42 forks source link

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

Closed nisargjhaveri closed 7 years ago

nisargjhaveri commented 7 years ago

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 commented 7 years ago

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

nisargjhaveri commented 7 years ago

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.

https://github.com/thomasjo/atom-latex/blob/dad1de7fbb4ff6d85b65c46b424ca59a622cd931/lib/openers/pdf-view-opener.js#L8-L13

Hope this helps! :)

yitzchak commented 7 years ago

@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.

nisargjhaveri commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

thomasjo commented 7 years ago

@nisargjhaveri Thanks for all your hard work on this issue! We really appreciate the help :bowing_man:

nisargjhaveri commented 7 years ago

No problem! Happy it got resolved! :D