Skip to content

Commit

Permalink
truncate file and allow directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakenelf committed Oct 31, 2021
1 parent 7297f0f commit 0a607e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dirfs/dirfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ func GetDirectoryItemSize(path string) (int64, error) {

// WriteToFile writes content to a file.
func WriteToFile(path, content string) error {
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
f, err := os.OpenFile(path, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
if err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/ui/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,10 @@ func (m *Model) handleEditFileKeyPress(cmds *[]tea.Cmd) {
*cmds = append(*cmds, m.handleErrorCmd(err))
}

if !m.showCommandInput && m.primaryPane.GetIsActive() && !selectedFile.IsDir() {
if !m.showCommandInput && m.primaryPane.GetIsActive() {
selectionPath := viper.GetString("selection-path")

if selectionPath == "" {
if selectionPath == "" && !selectedFile.IsDir() {
editorPath := os.Getenv("EDITOR")
if editorPath == "" {
*cmds = append(*cmds, m.handleErrorCmd(errors.New("$EDITOR not set")))
Expand Down

0 comments on commit 0a607e2

Please sign in to comment.