rename to Diff motif
This commit is contained in:
@@ -33,7 +33,7 @@ library
|
|||||||
Simplex.Chat.Core
|
Simplex.Chat.Core
|
||||||
Simplex.Chat.Help
|
Simplex.Chat.Help
|
||||||
Simplex.Chat.Markdown
|
Simplex.Chat.Markdown
|
||||||
Simplex.Chat.MarkdownEditing
|
Simplex.Chat.MarkdownDiff
|
||||||
Simplex.Chat.Messages
|
Simplex.Chat.Messages
|
||||||
Simplex.Chat.Messages.CIContent
|
Simplex.Chat.Messages.CIContent
|
||||||
Simplex.Chat.Migrations.M20220101_initial
|
Simplex.Chat.Migrations.M20220101_initial
|
||||||
@@ -390,7 +390,7 @@ test-suite simplex-chat-test
|
|||||||
ChatTests.Profiles
|
ChatTests.Profiles
|
||||||
ChatTests.Utils
|
ChatTests.Utils
|
||||||
MarkdownTests
|
MarkdownTests
|
||||||
MarkdownEditingTests
|
MarkdownDiffTests
|
||||||
MobileTests
|
MobileTests
|
||||||
ProtocolTests
|
ProtocolTests
|
||||||
SchemaDump
|
SchemaDump
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
{-# HLINT ignore "Use newtype instead of data" #-}
|
{-# HLINT ignore "Use newtype instead of data" #-}
|
||||||
|
|
||||||
|
|
||||||
module Simplex.Chat.MarkdownEditing
|
module Simplex.Chat.MarkdownDiff
|
||||||
( DiffedChar(..)
|
( DiffedChar(..)
|
||||||
, DiffedPlainChar(..)
|
, DiffedPlainChar(..)
|
||||||
, DiffStatus(..)
|
, DiffStatus(..)
|
||||||
@@ -14,8 +14,8 @@ module Simplex.Chat.MarkdownEditing
|
|||||||
, FormattedChar(..)
|
, FormattedChar(..)
|
||||||
, LeftSide(..)
|
, LeftSide(..)
|
||||||
, RightSide(..)
|
, RightSide(..)
|
||||||
, findDiffs
|
, diff
|
||||||
, findPlainDiffs
|
, plainDiff
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
|
|
||||||
@@ -73,10 +73,10 @@ newtype DeleteIndicies = DeleteIndicies (Seq Int) deriving (Show, Eq)
|
|||||||
newtype InsertIndicies = InsertIndicies (Seq Int) deriving (Show, Eq)
|
newtype InsertIndicies = InsertIndicies (Seq Int) deriving (Show, Eq)
|
||||||
|
|
||||||
|
|
||||||
findPlainDiffs :: LeftSide T.Text -> RightSide T.Text -> Seq DiffedPlainChar
|
plainDiff :: LeftSide T.Text -> RightSide T.Text -> Seq DiffedPlainChar
|
||||||
findPlainDiffs (LeftSide left) (RightSide right) = toPlain <$> diffs
|
plainDiff (LeftSide left) (RightSide right) = toPlain <$> formattedDiff
|
||||||
where
|
where
|
||||||
diffs = findDiffs (LeftSide $ toFormatted left) (RightSide $ toFormatted right)
|
formattedDiff = diff (LeftSide $ toFormatted left) (RightSide $ toFormatted right)
|
||||||
|
|
||||||
toPlain :: DiffedChar -> DiffedPlainChar
|
toPlain :: DiffedChar -> DiffedPlainChar
|
||||||
toPlain (DiffedChar (FormattedChar c _) diffStatus) = DiffedPlainChar c diffStatusPlain
|
toPlain (DiffedChar (FormattedChar c _) diffStatus) = DiffedPlainChar c diffStatusPlain
|
||||||
@@ -90,8 +90,8 @@ findPlainDiffs (LeftSide left) (RightSide right) = toPlain <$> diffs
|
|||||||
toFormatted = fmap (`FormattedChar` Nothing) . S.fromList . T.unpack
|
toFormatted = fmap (`FormattedChar` Nothing) . S.fromList . T.unpack
|
||||||
|
|
||||||
|
|
||||||
findDiffs :: LeftSide (Seq FormattedChar) -> RightSide (Seq FormattedChar) -> Seq DiffedChar
|
diff :: LeftSide (Seq FormattedChar) -> RightSide (Seq FormattedChar) -> Seq DiffedChar
|
||||||
findDiffs (LeftSide left) (RightSide right) = addInserts markDeletesAndUnchangedChars
|
diff (LeftSide left) (RightSide right) = addInserts markDeletesAndUnchangedChars
|
||||||
where
|
where
|
||||||
edits = D.diffTexts (toText left) (toText right)
|
edits = D.diffTexts (toText left) (toText right)
|
||||||
(DeleteIndicies deleteIndicies, InsertIndicies insertIndicies) = indices
|
(DeleteIndicies deleteIndicies, InsertIndicies insertIndicies) = indices
|
||||||
@@ -2,12 +2,12 @@
|
|||||||
{-# LANGUAGE OverloadedLists #-}
|
{-# LANGUAGE OverloadedLists #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
module MarkdownEditingTests where
|
module MarkdownDiffTests where
|
||||||
|
|
||||||
import qualified Data.Sequence as S
|
import qualified Data.Sequence as S
|
||||||
import Simplex.Chat.Markdown
|
import Simplex.Chat.Markdown
|
||||||
|
|
||||||
import Simplex.Chat.MarkdownEditing
|
import Simplex.Chat.MarkdownDiff
|
||||||
( FormattedChar(..),
|
( FormattedChar(..),
|
||||||
DiffedChar(..),
|
DiffedChar(..),
|
||||||
DiffedPlainChar(..),
|
DiffedPlainChar(..),
|
||||||
@@ -16,8 +16,8 @@ import Simplex.Chat.MarkdownEditing
|
|||||||
DiffFormatStatus(..),
|
DiffFormatStatus(..),
|
||||||
LeftSide(..),
|
LeftSide(..),
|
||||||
RightSide(..),
|
RightSide(..),
|
||||||
findDiffs,
|
diff,
|
||||||
findPlainDiffs )
|
plainDiff )
|
||||||
|
|
||||||
|
|
||||||
import System.Console.ANSI.Types
|
import System.Console.ANSI.Types
|
||||||
@@ -25,15 +25,15 @@ import Test.Hspec
|
|||||||
import qualified Data.List.NonEmpty as NE
|
import qualified Data.List.NonEmpty as NE
|
||||||
|
|
||||||
|
|
||||||
markdownEditingTests :: Spec
|
markdownDiffTests :: Spec
|
||||||
markdownEditingTests = do
|
markdownDiffTests = do
|
||||||
formattedEditedTextTests
|
formattedEditedTextTests
|
||||||
|
|
||||||
|
|
||||||
formattedEditedTextTests :: Spec
|
formattedEditedTextTests :: Spec
|
||||||
formattedEditedTextTests = describe "show edits" do
|
formattedEditedTextTests = describe "show edits" do
|
||||||
it "empty no change" do
|
it "empty no change" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[
|
[
|
||||||
])
|
])
|
||||||
@@ -45,7 +45,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "no change" do
|
it "no change" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
])
|
])
|
||||||
@@ -57,7 +57,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "add 1 char to empty" do
|
it "add 1 char to empty" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[
|
[
|
||||||
])
|
])
|
||||||
@@ -69,7 +69,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "del the one and only" do
|
it "del the one and only" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
])
|
])
|
||||||
@@ -81,7 +81,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "one character change" do
|
it "one character change" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
, FormattedChar 'r' Nothing
|
, FormattedChar 'r' Nothing
|
||||||
@@ -106,7 +106,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "more1" do
|
it "more1" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
, FormattedChar 'r' Nothing
|
, FormattedChar 'r' Nothing
|
||||||
@@ -137,7 +137,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "more2" do
|
it "more2" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
, FormattedChar 'r' Nothing
|
, FormattedChar 'r' Nothing
|
||||||
@@ -166,7 +166,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "more3" do
|
it "more3" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' (Just Bold)
|
[ FormattedChar 'H' (Just Bold)
|
||||||
, FormattedChar 'H' (Just Bold)
|
, FormattedChar 'H' (Just Bold)
|
||||||
@@ -198,7 +198,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "more4" do
|
it "more4" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar 'H' Nothing
|
[ FormattedChar 'H' Nothing
|
||||||
, FormattedChar 'r' Nothing
|
, FormattedChar 'r' Nothing
|
||||||
@@ -240,7 +240,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "SimplexLink 1" do
|
it "SimplexLink 1" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar '>' $ Just $ SimplexLink
|
[ FormattedChar '>' $ Just $ SimplexLink
|
||||||
{ linkType = XLContact
|
{ linkType = XLContact
|
||||||
@@ -274,7 +274,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "SimplexLink 2" do
|
it "SimplexLink 2" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar '>' $ Just $ SimplexLink
|
[ FormattedChar '>' $ Just $ SimplexLink
|
||||||
{ linkType = XLContact
|
{ linkType = XLContact
|
||||||
@@ -308,7 +308,7 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
]
|
]
|
||||||
|
|
||||||
it "SimplexLink 3" do
|
it "SimplexLink 3" do
|
||||||
findDiffs
|
diff
|
||||||
(LeftSide $ S.fromList
|
(LeftSide $ S.fromList
|
||||||
[ FormattedChar '>' $ Just $ SimplexLink
|
[ FormattedChar '>' $ Just $ SimplexLink
|
||||||
{ linkType = XLContact
|
{ linkType = XLContact
|
||||||
@@ -341,8 +341,8 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
it "findPlainDiffs 1" do
|
it "plainDiff 1" do
|
||||||
findPlainDiffs
|
plainDiff
|
||||||
(LeftSide "https://api.twitter.com/2/tweets/:id")
|
(LeftSide "https://api.twitter.com/2/tweets/:id")
|
||||||
(RightSide "https://api.twitter.com/3/tweets/:id")
|
(RightSide "https://api.twitter.com/3/tweets/:id")
|
||||||
`shouldBe` S.fromList
|
`shouldBe` S.fromList
|
||||||
@@ -385,8 +385,8 @@ formattedEditedTextTests = describe "show edits" do
|
|||||||
, DiffedPlainChar 'd' UnchangedP
|
, DiffedPlainChar 'd' UnchangedP
|
||||||
]
|
]
|
||||||
|
|
||||||
it "findPlainDiffs 2" do
|
it "plainDiff 2" do
|
||||||
findPlainDiffs
|
plainDiff
|
||||||
(LeftSide "Hrl~!@lo")
|
(LeftSide "Hrl~!@lo")
|
||||||
(RightSide "Herxy!@zo12")
|
(RightSide "Herxy!@zo12")
|
||||||
`shouldBe` S.fromList
|
`shouldBe` S.fromList
|
||||||
@@ -3,7 +3,7 @@ import ChatTests
|
|||||||
import Control.Logger.Simple
|
import Control.Logger.Simple
|
||||||
import Data.Time.Clock.System
|
import Data.Time.Clock.System
|
||||||
import MarkdownTests
|
import MarkdownTests
|
||||||
import MarkdownEditingTests
|
import MarkdownDiffTests
|
||||||
import MobileTests
|
import MobileTests
|
||||||
import ProtocolTests
|
import ProtocolTests
|
||||||
import SchemaDump
|
import SchemaDump
|
||||||
@@ -16,7 +16,7 @@ main :: IO ()
|
|||||||
main = do
|
main = do
|
||||||
setLogLevel LogError -- LogDebug
|
setLogLevel LogError -- LogDebug
|
||||||
withGlobalLogging logCfg . hspec $ do
|
withGlobalLogging logCfg . hspec $ do
|
||||||
describe "SimpleX chat markdown editing" markdownEditingTests
|
describe "SimpleX chat markdown diff" markdownDiffTests
|
||||||
-- describe "SimpleX chat markdown" markdownTests
|
-- describe "SimpleX chat markdown" markdownTests
|
||||||
-- describe "SimpleX chat view" viewTests
|
-- describe "SimpleX chat view" viewTests
|
||||||
-- describe "SimpleX chat protocol" protocolTests
|
-- describe "SimpleX chat protocol" protocolTests
|
||||||
|
|||||||
Reference in New Issue
Block a user