diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d35c83..40d993d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ SPDX-License-Identifier: MIT # Changelog for rusty-man +## Unreleased + +- Improve handling of different items with same name: + - Add the item type to the item list if multiple matches are found in the + search index. + ## v0.2.0 (2020-08-11) This minor release adds support for syntax highlighting of code snippets and diff --git a/src/index.rs b/src/index.rs index 2d896e2..9544cfe 100644 --- a/src/index.rs +++ b/src/index.rs @@ -31,15 +31,16 @@ pub struct Index { #[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)] pub struct IndexItem { pub name: doc::Fqn, + pub ty: doc::ItemType, pub description: String, } impl fmt::Display for IndexItem { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { if self.description.is_empty() { - write!(f, "{}", &self.name) + write!(f, "{} ({})", &self.name, self.ty.name()) } else { - write!(f, "{}: {}", &self.name, &self.description) + write!(f, "{} ({}): {}", &self.name, self.ty.name(), &self.description) } } } @@ -194,6 +195,7 @@ impl Index { log::info!("Found index match '{}'", full_name); matches.push(IndexItem { name: full_name, + ty: item.ty, description: item.desc.clone(), }); }