Skip to content

Commit

Permalink
clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Feel-ix-343 committed Apr 3, 2024
1 parent 35d91e0 commit 397f57d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/completion/link_completer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,11 @@ impl LinkCompletion<'_> {

fn default_completion<'a>(
&self,
refname: &str,
text_edit: CompletionTextEdit,
filter_text: &str,
vault: &Vault,
completer: &impl LinkCompleter<'a>,
) -> CompletionItem {
let vault = completer.vault();
let referenceable = match self {
Self::File { referenceable, .. }
| Self::Heading { referenceable, .. }
Expand All @@ -553,8 +552,10 @@ impl LinkCompletion<'_> {
Self::DailyNote(daily) => daily.referenceable(completer),
};

let label = self.match_string();

CompletionItem {
label: refname.to_string(),
label: label.to_string(),
kind: Some(match self {
Self::File {
mdfile: _,
Expand Down Expand Up @@ -664,15 +665,13 @@ impl<'a> Completable<'a, MarkdownLinkCompleter<'a>> for LinkCompletion<'a> {
let text_edit =
markdown_link_completer.completion_text_edit(Some(&link_display_text), &refname);

let filter_text = markdown_link_completer.completion_filter_text(match_string);
let filter_text = markdown_link_completer.completion_filter_text(match_string); // TODO: abstract into default_completion

Some(CompletionItem {
insert_text_format: Some(InsertTextFormat::SNIPPET),
..self.default_completion(
match_string,
text_edit,
&filter_text,
markdown_link_completer.vault(),
markdown_link_completer,
)
})
Expand All @@ -692,10 +691,8 @@ impl<'a> Completable<'a, WikiLinkCompleter<'a>> for LinkCompletion<'a> {
let filter_text = completer.completion_filter_text(match_text);

Some(self.default_completion(
match_text,
text_edit,
&filter_text,
completer.vault(),
completer,
))
}
Expand Down

0 comments on commit 397f57d

Please sign in to comment.