-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add option to edit current document #225
Conversation
Calling `showStatusMessage(note)` always displays "Stashed!". This fixes the method to allow the intuitive behavior and display the parameter passed as a status message.
Added an option to edit the opened document when the user types 'e'. Searches $PATH first for the command specified by $EDITOR and then for a set of pre-defined command line text editors. Addresses: charmbracelet#182
So I'm realizing now which parts of this should be (non-)blocking. Launching the editor needs to be blocking. But once the edits are made, saving the local file / stashing the changes should be done asynchronously. Working on that now |
Should complete this feature for now. Asynchronous methods added for stashing or writing edits. Also tracks the ID of edited stashes better so that future editing / revisiting a file is no longer buggy.
Alright, as far as I can tell, this is in a pretty good state. Found no bugs while testing. Code is much more organized. Stuff that should block blocks and stuff that shouldn't doesn't. |
Thank you for the PR! Just a heads up that we're working on an update to Glow that will most likely conflict with this, though we're happy to look at those conflicts on our end. The holidays are also upon us so it may be a little bit before we give this PR a proper review. |
Baha, no worries. I'm happy to look over it, too. If there's a fork or branch where the update is being worked on, I could look over adjusting my code to work with it |
Cool, we'll push something up early next week. We may contribute to your branch as well. |
So I've been testing this out with various editors. It behaves oddly with GUI editors.
A couple possible solutions:
I'm already using However, I haven't the slightest idea how to detect if the editor is GUI or console based, but intuition says... while nothing is technically "impossible" when programming, this probably leans towards more complex than it's worth. If that's the case, I currently don't have a good idea for returning control back to |
Having a direct editing feature would be awesome! |
@shitchell curious if you tried using |
Hey @shitchell, thank you so much for this PR! Open in editor was added to Glow recently in: You can now press e on any local document to edit it. |
Implements #182
Allows the user to edit the current document by typing 'e'. If
$EDITOR
is set, a temporary file is created with the contents of the current document, and the specified editor is used to open it. If no changes are made when the editor exits, nothing happens. If changes are made, then:if the document is a local file, the edits are written to that file
if the document is stashed, a new stash is created with the edits, and the old stash is deleted.
It would be ideal to simply update the contents of a stash, but the charm API doesn't currently allow this. Deleting the selected stash has the side effect that, when the user returns to the list of files and tries to re-open the same document, the stash won't load. Restarting
glow
solves this and shows the newly created, updated stash.charmbracelet/charm#13 creates a
SetMarkdownBody()
method to resolve this minor issue.