fix(diary): complete the -count wiki selector (repair 874bdd0)
874bdd0 committed the diary -count feature with several Edits that had
silently no-matched, leaving the tree non-compiling and the clients
inconsistent (CI run 236 failed). This completes it:
- commands.rs: add the `wiki` field to OptionalUriArg (the previous edit
targeted a wrong struct name) and pass None to the six resolve_diary_wiki
callers that take no selector (date/list/step paths). Server builds clean.
- autoload/nuwiki/commands.vim + lua/nuwiki/commands.lua: actually thread the
count through s:diary_open / _diary_open and the diary_today/today_tab/
yesterday/tomorrow/index handlers (these edits had failed before, so the
ftplugin defs were calling handlers that ignored/rejected the arg).
- Add the test cases the prior commit referenced but never landed:
cmd.VimwikiMakeDiaryNote_has_count (test-keymaps.lua) +
cmd.Vimwiki{MakeDiaryNote,DiaryIndex}_accepts_count (test-keymaps-vim.vim).
- Fix the OptUriArg→OptionalUriArg name in the gap-doc note.
Verified with CI flags: workspace test/clippy/fmt clean; lua 284, vim 272/18/21,
all 0 failed; the three new diary cases pass.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -308,6 +308,11 @@ fn parse_uri_arg(args: Vec<Value>) -> Result<UriArg, String> {
|
||||
struct OptionalUriArg {
|
||||
#[serde(default)]
|
||||
uri: Option<Url>,
|
||||
/// Optional wiki selector (vimwiki's diary `-count`): the client sends a
|
||||
/// 0-indexed wiki number when the user gave a count. When present it wins
|
||||
/// over `uri`-based resolution (see `resolve_diary_wiki`).
|
||||
#[serde(default)]
|
||||
wiki: Option<Value>,
|
||||
}
|
||||
|
||||
fn parse_optional_uri_arg(args: Vec<Value>) -> Result<OptionalUriArg, String> {
|
||||
@@ -522,7 +527,7 @@ fn diary_list(backend: &Backend, args: Vec<Value>) -> Result<Option<Value>, Stri
|
||||
Some(v) => serde_json::from_value(v).map_err(|e| format!("invalid args: {e}"))?,
|
||||
None => Args::default(),
|
||||
};
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref()) else {
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref(), None) else {
|
||||
return Ok(Some(serde_json::json!([])));
|
||||
};
|
||||
let entries = {
|
||||
@@ -556,7 +561,7 @@ fn diary_open_for_date(backend: &Backend, args: Vec<Value>) -> Result<Option<Val
|
||||
parsed.date
|
||||
));
|
||||
};
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref()) else {
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref(), None) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let Some(uri) = crate::diary::uri_for_date(&wiki.config, &date) else {
|
||||
@@ -579,7 +584,7 @@ fn tags_search(backend: &Backend, args: Vec<Value>) -> Result<Option<Value>, Str
|
||||
Some(v) => serde_json::from_value(v).map_err(|e| format!("invalid args: {e}"))?,
|
||||
None => Args::default(),
|
||||
};
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref()) else {
|
||||
let Some(wiki) = resolve_diary_wiki(backend, parsed.uri.as_ref(), None) else {
|
||||
return Ok(Some(serde_json::json!([])));
|
||||
};
|
||||
let hits = {
|
||||
@@ -653,7 +658,7 @@ fn tags_rebuild(backend: &Backend, args: Vec<Value>) -> Result<Option<Value>, St
|
||||
let targets: Vec<crate::wiki::Wiki> = if all {
|
||||
backend.wikis_snapshot()
|
||||
} else {
|
||||
match resolve_diary_wiki(backend, p.uri.as_ref()) {
|
||||
match resolve_diary_wiki(backend, p.uri.as_ref(), None) {
|
||||
Some(w) => vec![w],
|
||||
None => return Ok(None),
|
||||
}
|
||||
@@ -1171,7 +1176,7 @@ fn export_current(
|
||||
|
||||
fn export_all(backend: &Backend, args: Vec<Value>, force: bool) -> Result<Option<Value>, String> {
|
||||
let p = parse_optional_uri_arg(args)?;
|
||||
let Some(wiki) = resolve_diary_wiki(backend, p.uri.as_ref()) else {
|
||||
let Some(wiki) = resolve_diary_wiki(backend, p.uri.as_ref(), None) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let cfg = wiki.config.clone();
|
||||
@@ -1248,7 +1253,7 @@ fn export_all(backend: &Backend, args: Vec<Value>, force: bool) -> Result<Option
|
||||
|
||||
fn export_rss(backend: &Backend, args: Vec<Value>) -> Result<Option<Value>, String> {
|
||||
let p = parse_optional_uri_arg(args)?;
|
||||
let Some(wiki) = resolve_diary_wiki(backend, p.uri.as_ref()) else {
|
||||
let Some(wiki) = resolve_diary_wiki(backend, p.uri.as_ref(), None) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let entries = {
|
||||
|
||||
Reference in New Issue
Block a user