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 * sqlite database storage
* fast search * fast search
* quick access using unique aliases * quick and direct access to a note using a unique alias
* marking important notes * mark important notes
## Install or upgrade ## Install or upgrade

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

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

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

Loading…
Cancel
Save