Skip to content

Commit

Permalink
Merge pull request #319 from jaroslawhartman/pet-main-knqyf263-issue-314
Browse files Browse the repository at this point in the history
Fix for #314 - unnecessary +0 as a cmd parameter in editFile
  • Loading branch information
RamiAwar authored Nov 7, 2024
2 parents 96912fe + 1372cf8 commit adfb69a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
"bytes"
"fmt"
"io"
"os"
"strconv"
"strings"

"github.com/fatih/color"
Expand All @@ -14,13 +12,6 @@ import (
"github.com/knqyf263/pet/snippet"
)

func editFile(command, file string, startingLine int) error {
// Note that this works for most unix editors (nano, vi, vim, etc)
// TODO: Remove for other kinds of editors - this is only for UX
command += " +" + strconv.Itoa(startingLine) + " " + file
return run(command, os.Stdin, os.Stdout)
}

func filter(options []string, tag string) (commands []string, err error) {
var snippets snippet.Snippets
if err := snippets.Load(true); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions cmd/util_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"os/exec"
"strconv"

"github.com/knqyf263/pet/config"
)
Expand All @@ -23,3 +24,8 @@ func run(command string, r io.Reader, w io.Writer) error {
cmd.Stdin = r
return cmd.Run()
}

func editFile(command, file string, startingLine int) error {
command += " +" + strconv.Itoa(startingLine) + " " + file
return run(command, os.Stdin, os.Stdout)
}
5 changes: 5 additions & 0 deletions cmd/util_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@ func run(command string, r io.Reader, w io.Writer) error {
cmd.Stdin = r
return cmd.Run()
}

func editFile(command, file string, startingLine int) error {
command += " " + file
return run(command, os.Stdin, os.Stdout)
}

0 comments on commit adfb69a

Please sign in to comment.