From 7cf1f7b7bb85a385431ce4acd23a0b4e03be81d0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 6 Oct 2023 19:05:56 -0400 Subject: [PATCH] Only orgify the link text if there are line breaks present. --- .../object/regular_link/file_link.org | 1 + src/compare/diff.rs | 4 +-- src/types/object.rs | 25 +++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/org_mode_samples/object/regular_link/file_link.org b/org_mode_samples/object/regular_link/file_link.org index 58f6204..95a0d5f 100644 --- a/org_mode_samples/object/regular_link/file_link.org +++ b/org_mode_samples/object/regular_link/file_link.org @@ -1,4 +1,5 @@ [[file:simple.org]] +[[file:sim ple.org]] [[file:simp le.org]] diff --git a/src/compare/diff.rs b/src/compare/diff.rs index de11235..5114e81 100644 --- a/src/compare/diff.rs +++ b/src/compare/diff.rs @@ -2805,8 +2805,8 @@ fn compare_regular_link<'b, 's>( ), ( EmacsField::Required(":search-option"), - |r| r.search_option, - compare_property_quoted_string + |r| r.get_search_option(), + compare_property_quoted_string_owned ) )? { this_status = new_status; diff --git a/src/types/object.rs b/src/types/object.rs index fb96429..9185e9e 100644 --- a/src/types/object.rs +++ b/src/types/object.rs @@ -683,11 +683,32 @@ pub(crate) fn orgify_text<'s>(raw_text: &'s str) -> String { } impl<'s> RegularLink<'s> { + /// Orgify the raw_link if it contains line breaks. pub fn get_raw_link(&self) -> String { - orgify_text(self.raw_link) + if self.raw_link.contains('\n') { + orgify_text(self.raw_link) + } else { + self.raw_link.to_owned() + } } + /// Orgify the path if it contains line breaks. pub fn get_path(&self) -> String { - orgify_text(self.path) + if self.path.contains('\n') { + orgify_text(self.path) + } else { + self.path.to_owned() + } + } + + /// Orgify the search_option if it contains line breaks. + pub fn get_search_option(&self) -> Option { + self.search_option.map(|search_option| { + if search_option.contains('\n') { + orgify_text(search_option) + } else { + search_option.to_owned() + } + }) } }