asamuzaK / withExEditorHost

Native messaging host for withExEditor
MIT License
33 stars 8 forks source link

Workflow with iterative edits #107

Closed richardb64 closed 2 years ago

richardb64 commented 2 years ago

A common workflow that worked with ItsAllText goes something like this (using MediaWiki as an example):

  1. Open the page edit tab.
  2. Click the "Show preview" button once (a workaround for a field naming issue that affected IAT too).
  3. Invoke the external editor on the main edit box.
  4. Edit the text.
  5. Save the text in the external editor, without closing it.
  6. Observe that the browser has updated to track the latest edits.
  7. Click the "Show preview" button to view the formatted results.
  8. Repeat from 4 as required.

With WEE, as has been reported in some other issues (notably #28) and AMO comments, this doesn't work.

I can save the text multiple times (ie. repeating just steps 4-6), and the browser tracks the changes. But as soon as the page refreshes (step 7), the editor becomes permanently detached. Future saves are not picked up by the browser, and are lost if you then close the external editor.

Can this be fixed, or does the WebExtensions model mean it's impossible to have a "persistent" linkage that survives page reloads?

asamuzaK commented 2 years ago

Try below.

  1. Right click on the main text field again, and click Edit Text with YourEditor menu item.
  2. The local file should be synced again.
  3. Repeat from 4 as needed.
richardb64 commented 2 years ago

That does kinda work, thanks. It's a bit messy, though - unless the configured editor knows how to switch focus to the original window when asked to re-open a file that's already being edited, it opens a new window on the same file as before. My preferred editor (gvim) then complains because it knows the file is already "locked" by the original editing session - I'd guess other editors would do something similar (or silently do the wrong thing!).

I've done a bit more experimenting, and by using gvim in "clientserver" mode, I've been able to avoid most of the above. But if I forget to re-invoke WEE every time, I still lose any edits I've made since the last sync.

Is it possible for WEE to query WEEH to see if there is already a file present, with an active editor session, and automatically resync if it finds one (or rather, re-establish the "watcher" and resync next time the editor updates the file)?

asamuzaK commented 2 years ago

Change your editor setting https://superuser.com/questions/181377/auto-reloading-a-file-in-vim-as-soon-as-it-changes-on-disk

asamuzaK commented 2 years ago

If the web page moves to another page or reloaded, the port is disconnected. And when the add-on detects that the port has been disconnected, both add-on's background script and the host removes the data they previously held. Keeping data in place can lead to memory leaks.