mirror of
https://github.com/rwinkhart/libmutton.git
synced 2026-08-27 20:36:29 -04:00
Trim trailing spaces from copied note line (in case user added trailing spaces for Markdown formatting)
This commit is contained in:
+7
-2
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/rwinkhart/go-boilerplate/back"
|
"github.com/rwinkhart/go-boilerplate/back"
|
||||||
"github.com/rwinkhart/libmutton/crypt"
|
"github.com/rwinkhart/libmutton/crypt"
|
||||||
@@ -33,7 +34,8 @@ func CopyShortcut(realPath string, field int, rcwPassword []byte) error {
|
|||||||
return errors.New("field is empty")
|
return errors.New("field is empty")
|
||||||
}
|
}
|
||||||
|
|
||||||
if field == 2 { // TOTP mode
|
switch field {
|
||||||
|
case 2: // TOTP
|
||||||
fmt.Println(back.AnsiWarning + "[Starting]" + back.AnsiReset + " TOTP clipboard refresher")
|
fmt.Println(back.AnsiWarning + "[Starting]" + back.AnsiReset + " TOTP clipboard refresher")
|
||||||
errorChan := make(chan error, 1)
|
errorChan := make(chan error, 1)
|
||||||
go TOTPCopier(decSlice[2], errorChan, nil) // "done" is not needed because the process runs until the program is killed
|
go TOTPCopier(decSlice[2], errorChan, nil) // "done" is not needed because the process runs until the program is killed
|
||||||
@@ -41,7 +43,10 @@ func CopyShortcut(realPath string, field int, rcwPassword []byte) error {
|
|||||||
return errors.New("error encountered in TOTP refresh process: " + err.Error())
|
return errors.New("error encountered in TOTP refresh process: " + err.Error())
|
||||||
}
|
}
|
||||||
select {} // block indefinitely
|
select {} // block indefinitely
|
||||||
} else { // other
|
case 4:
|
||||||
|
decSlice[field] = strings.TrimRight(decSlice[field], " ")
|
||||||
|
fallthrough
|
||||||
|
default:
|
||||||
// copy field to clipboard; launch clipboard clearing process
|
// copy field to clipboard; launch clipboard clearing process
|
||||||
if err = CopyBytes(true, []byte(decSlice[field])); err != nil {
|
if err = CopyBytes(true, []byte(decSlice[field])); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user