Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

server: extend tag completion #76

Merged
merged 3 commits into from
Aug 22, 2020
Merged

server: extend tag completion #76

merged 3 commits into from
Aug 22, 2020

Conversation

Kamuso
Copy link
Collaborator

@Kamuso Kamuso commented Aug 16, 2020

Closes #17, closes #25
Left out #54 because we pretty much have the "all categories" functionality by just not specifying a category, and undefined is used for regular tags.

db/tags.go Outdated
case "undefined":
prefix += s[:i+1]
s = s[i+1:]
typeQ = fmt.Sprintf(" and type = %d", common.Undefined)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move all cases of this into an embedded function to DRY this a bit.
Something like

completeWithPrefix := func (t common.TagType) {
  prefix += s[:i+1]
  s = s[i+1:]
  typeQ = fmt.Sprintf(" and type = %d", t)
}

db/tags.go Outdated
if s[i+1:] != "" {
if s[i+1] == '-' {
prefix = "order:-"
re = regexp.MustCompile(`^` + regexp.QuoteMeta(s[i+2:]) + `.*`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return error instead of panicking.

db/tags.go Outdated
}
} else {
// Complete prefix
re := regexp.MustCompile(`^` + regexp.QuoteMeta(s) + `.*`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return error instead of panicking.

@Kamuso
Copy link
Collaborator Author

Kamuso commented Aug 16, 2020

Ok, updated. So what about #54, should it be closed?

@Kamuso
Copy link
Collaborator Author

Kamuso commented Aug 17, 2020

While I'm here, fixed a bug.

@bakape
Copy link
Owner

bakape commented Aug 22, 2020

Okay, thank you!

@bakape bakape merged commit e20b1fc into master Aug 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autocomplete system tags Autocomplete tags with prefixes
2 participants