if EDITOR exists with status other than 0, print edited filepath

master
Sina Siadat 9 years ago
parent 63c82135b5
commit 375c041c9e

@ -4,8 +4,8 @@ eton is a note-taking cli tool.
* sqlite database storage
* fast search
* quick access using unique aliases
* marking important notes
* quick and direct access to a note using a unique alias
* mark important notes
## Install or upgrade

@ -228,7 +228,7 @@ func (attr Attr) Print(w *tabwriter.Writer, verbose bool, indent int, highlighte
if attr.GetMark() == 0 {
fmt.Fprintf(out, "[%s] %s\n", Color(attr.GetIdentifier(), "yellow+b"), attr.Title())
} else {
fmt.Fprintf(out, "%s %s\n", Color("["+attr.GetIdentifier()+"]", "black+b:white"), Color(attr.Title(), "default"))
fmt.Fprintf(out, "%s %s\n", Color("("+attr.GetIdentifier()+")", "black+b:white"), Color(attr.Title(), "default"))
}
if len(highlighteds) > 0 {
fmt.Fprintln(out, attr.PrettyMatches(highlighteds, after))
@ -254,12 +254,13 @@ func (attr Attr) PrettyMatches(highlighteds []string, after int) string {
line, matched := highlightLine(line, highlighteds)
if matched {
lastMatchingLine = linenumber
if true { // !isCoveredByLastMatch {
if true || !isCoveredByLastMatch {
matchCounter += 1
}
}
if matched || isCoveredByLastMatch {
prefix := fmt.Sprintf("%s L%s:", strings.Repeat(" ", len(attr.GetIdentifier())), strconv.Itoa(linenumber+1))
//prefix := fmt.Sprintf("%s L%s:", strings.Repeat(" ", len(attr.GetIdentifier())), strconv.Itoa(linenumber+1))
prefix := fmt.Sprintf("%s", strings.Repeat(" ", 3+len(attr.GetIdentifier())))
matchinglines = append(matchinglines, Color(prefix, "black")+line)
if maximumShownMatches != -1 && matchCounter >= maximumShownMatches {
break

@ -20,7 +20,7 @@ var globalDB *sql.DB
var globalOpts Options
// const orderby = "-frequency, -mark, CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC"
const orderby = "CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC"
const orderby = "-mark, CASE WHEN updated_at IS NULL THEN created_at ELSE updated_at END DESC"
const defaultEditor = "vi"
func cmdShow(db *sql.DB, opts Options) bool {
@ -394,7 +394,8 @@ func openEditor(filepath string) bool {
cmd.Stdout = os.Stdout
err := cmd.Run()
if err != nil {
log.Println(err)
log.Println("Error:", err)
log.Println("File not saved:", filepath)
return false
}
return true

@ -9,7 +9,7 @@ import (
const novalue string = "nil"
const datelayout string = "06/01/02 03:04pm"
const ellipsis = "…"
const maximumShownMatches = -1 // -1
const maximumShownMatches = -1
type Options struct {
ID int64

Loading…
Cancel
Save