Skip to content

Commit cb4ec91

Browse files
Fix the merging of built in and custom search templates
1 parent 594ad51 commit cb4ec91

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

internal/templates/templates.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
func GetSearchTemplates() ([]SearchTemplate, error) {
1616
var searchTemplates []SearchTemplate
1717
var templates []SearchTemplate
18+
var builtInTemplates []SearchTemplate
1819
home, err := os.UserHomeDir()
1920
if err != nil {
2021
return nil, err
@@ -49,21 +50,21 @@ func GetSearchTemplates() ([]SearchTemplate, error) {
4950

5051
err = json.Unmarshal(raw, &templates)
5152
if err != nil {
52-
log.Error("an error occured while parsing the file: %s", templateFile)
53+
log.Error("an error occurred while parsing the file: %s", templateFile)
5354
return nil, err
5455
}
5556

5657
searchTemplates = append(searchTemplates, templates...)
5758
}
5859
}
5960

60-
err = json.Unmarshal([]byte(builtInSearchTemplates), &templates)
61+
err = json.Unmarshal([]byte(builtInSearchTemplates), &builtInTemplates)
6162
if err != nil {
62-
color.Red("an error occured while parsing the built in templates")
63+
color.Red("an error occurred while parsing the built in templates")
6364
return nil, err
6465
}
6566

66-
searchTemplates = append(searchTemplates, templates...)
67+
searchTemplates = append(searchTemplates, builtInTemplates...)
6768

6869
for i := 0; i < len(searchTemplates); i++ {
6970
entry := &searchTemplates[i]
@@ -115,7 +116,7 @@ func GetExportTemplates() ([]ExportTemplate, error) {
115116

116117
err = json.Unmarshal(raw, &templates)
117118
if err != nil {
118-
log.Debug("an error occured while parsing the file: %s", templateFile)
119+
log.Debug("an error occurred while parsing the file: %s", templateFile)
119120
return nil, err
120121
}
121122

@@ -125,7 +126,7 @@ func GetExportTemplates() ([]ExportTemplate, error) {
125126

126127
err = json.Unmarshal([]byte(builtInExportTemplates), &templates)
127128
if err != nil {
128-
log.Error("an error occured while parsing the built in templates")
129+
log.Error("an error occurred while parsing the built in templates")
129130
return nil, err
130131
}
131132

0 commit comments

Comments
 (0)