diff --git a/proto/anki/tags.proto b/proto/anki/tags.proto index a0e39ae86..c2ff124cb 100644 --- a/proto/anki/tags.proto +++ b/proto/anki/tags.proto @@ -63,7 +63,7 @@ message FindAndReplaceTagRequest { message CompleteTagRequest { // a partial tag, optionally delimited with :: string input = 1; - uint32 amount = 2; + uint32 match_limit = 2; } message CompleteTagResponse { diff --git a/rslib/src/backend/tags.rs b/rslib/src/backend/tags.rs index 8a788df16..5601efcc4 100644 --- a/rslib/src/backend/tags.rs +++ b/rslib/src/backend/tags.rs @@ -91,7 +91,7 @@ impl TagsService for Backend { fn complete_tag(&self, input: pb::CompleteTagRequest) -> Result { self.with_col(|col| { - let tags = col.complete_tag(&input.input, input.amount)?; + let tags = col.complete_tag(&input.input, input.match_limit as usize)?; Ok(pb::CompleteTagResponse { tags }) }) } diff --git a/rslib/src/tags/complete.rs b/rslib/src/tags/complete.rs index 0c5cb723a..1093017b0 100644 --- a/rslib/src/tags/complete.rs +++ b/rslib/src/tags/complete.rs @@ -2,19 +2,18 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use regex::Regex; -use std::convert::TryInto; use crate::prelude::*; impl Collection { - pub fn complete_tag(&self, input: &str, amount: u32) -> Result> { + pub fn complete_tag(&self, input: &str, limit: usize) -> Result> { let filters: Vec<_> = input .split("::") .map(component_to_regex) .collect::>()?; let mut tags = vec![]; self.storage.get_tags_by_predicate(|tag| { - if tags.len() <= amount.try_into().unwrap() && filters_match(&filters, tag) { + if tags.len() <= limit && filters_match(&filters, tag) { tags.push(tag.to_string()); } // we only need the tag name diff --git a/ts/editor/TagEditor.svelte b/ts/editor/TagEditor.svelte index b85d8e88b..854a160a1 100644 --- a/ts/editor/TagEditor.svelte +++ b/ts/editor/TagEditor.svelte @@ -58,7 +58,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html const data = await postRequest( "/_anki/completeTag", Tags.CompleteTagRequest.encode( - Tags.CompleteTagRequest.create({ input, amount: 500 }) + Tags.CompleteTagRequest.create({ input, matchLimit: 500 }) ).finish() ); const response = Tags.CompleteTagResponse.decode(data);