Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always display latest version of file #564

Merged
merged 1 commit into from
Feb 21, 2016
Merged

Always display latest version of file #564

merged 1 commit into from
Feb 21, 2016

Conversation

getaaron
Copy link
Collaborator

This PR closes #559, closes #529, closes #349, closes #351, and closes #48. All of these issues are approximately duplicates of the same issue, which is that files modified by other applications aren't reflected in MacDown.

These changes are automatically passed to [NSDocument -readFromData:ofType:error:]. All this change does is update the display with the changes, rather than ignore them, which is what's happening now.

Here's how it looks with the new behavior:

display-external-changes

As a reminder, here's the old behavior, in which MacDown overwrites external changes without warning:

old-behavior

@Jmuccigr
Copy link
Contributor

I like this behavior. Well done!

@uranusjr uranusjr merged commit e8c1863 into MacDownApp:master Feb 21, 2016
@eddiexue
Copy link

wait for this feature for long time,thank you~!

@uranusjr uranusjr mentioned this pull request Mar 1, 2016
@kohanyirobert
Copy link

I'm using MacDown 0.6 on El Capitan, but this doesn't seem to work for me.

I'm using MacVim, to create a file at ~/my.md. Write some Markdown stuff in it. I open the file in MacDown. I line up the editors side by side on my screen and I go back to MacVim. I edit the file, save the buffer, but MacDown doesn't load the changes I made in MacVim. Even if I switch the focus to MacDown it does not load the changes ... if I try to edit the file in MacDown and save it after that it tells me that the file was changed by an external application. At that point if I click Revert MacDown will properly reload the file.

Do I need to do anything special to enable this feature? What am I doing wrong? Or did I totally misunderstand the nature of the feature/fix?

@mgsxx
Copy link

mgsxx commented Jun 11, 2016

El Capitan 10.11.5, MacDown 0.6 (749)

The setup: one file opened in MacDown and BBEdit - works OK. If I change the file in MacDown the changes appear in BBEdit and vice versa.

But! The file is in the Dropbox folder. And when I change the file on my iPad (no matter in what program) and Dropbox syncs the changes on my Mac MacDown won't reflect the changes. While BBEdit does reflect them.

So MacDown fails in this case.

@harry-m
Copy link

harry-m commented Aug 26, 2016

This also doesn't work for me. Following the same steps as @kohanyirobert, I get the same behaviour. I was expecting to change the file in vim, then return focus to MacDown and see my change appear with no further input.

For me this problem is manifesting mostly when I switch branches in git - I have to remember to close and re-open the file in MacDown, which is frustrating.

MacDown 0.6 (749) and Yosemite 10.10.5.

@smdowl
Copy link

smdowl commented Aug 27, 2016

Also doesn't work for me with same setup as Harry (MacDown 0.6 (749) and Yosemite 10.10.5).

In my case I am regenerating the file that I had open in MacDown. When I got back to MacDown it is stuck on the old version.

Great feature though, and will genuinely be a gamechanger for me if you can get it working!

@uranusjr
Copy link
Member

Maybe we should just use low-level API to listen to file change notifications and update explicitly. Does anyone know of a good framework for this?

@FranklinYu
Copy link
Member

FranklinYu commented Aug 29, 2016

I just asked Google and it gave me two: File System Events and Kernel Queues, but both documentations suggest that Kernel Queues are more appropriate for monitoring a single file. Its manual page is here.

@repomorphism
Copy link

TeXShop does this and might be a good reference. Looks to me that they use something in the GCD family but I'm not good enough to understand it.

@FranklinYu
Copy link
Member

@es2mac I scanned the source. It seems to be related to Dispatch Sources about which I never knew, but it seems promising.

@uranusjr
Copy link
Member

uranusjr commented Sep 1, 2016

@FranklinYu @es2mac I knew about File System Events, but do not want to use it because it is just too tedious and complex. Kqueue looks much better. I also found VDKQueue which seems to be a nice Objective-C wrapper. Dispatch Sources looks even simpler, but I haven’t found much discussion around it.

I think I will go with Dispatch Sources for now, but also build a wrapper around it so that we can switch camp if needed. Thanks for the pointer!

@uranusjr
Copy link
Member

uranusjr commented Sep 1, 2016

OK so I tried to implement this in a seperate branch. You can follow the referral link above to see the change, and a link to a test build. Please give it a try and tell me what you think. Thanks!

@nictuku
Copy link

nictuku commented Nov 24, 2017

Hi. Are there plans to fix MacDown's auto-reload of files on OSX? Thank you for the great work by the way.

@FranklinYu
Copy link
Member

@nictuku We have tried something in #651, but get confused about some weird behavior of preview pane. Apple did not seem to provide enough documentation here, and you can take a look at that if you knows Objective-C. Or you can track #576 instead.

@timotheecour
Copy link

ping on this? still not working on OSX; when editing file in sublimetext, change is not reflected in macdown

@getaaron getaaron deleted the display-latest-file branch March 26, 2018 18:34
@getaaron
Copy link
Collaborator Author

@timotheecour this PR was merged already. Please create a new issue or comment on an open issue if you’re still having issues with the latest version

@Gidgidonihah
Copy link

Gidgidonihah commented Mar 26, 2018

For reference, there is already another issue open. It's #630

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment