Skip to content

Commit

Permalink
feat(resolver): subOperation 속성으로 delete라인 적용 여부 판단
Browse files Browse the repository at this point in the history
  • Loading branch information
5ewon committed Apr 27, 2024
1 parent a51745f commit 937c61e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions components/Resolver/resolver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import * as styles from "./style.css";
interface LineObject {
index?: number;
operation: string;
subOperation?: string;
text: string;
}

Expand Down Expand Up @@ -66,11 +67,12 @@ const Resolver = ({ title, contents }: PropsType) => {
if (range.includes("[/delete]") && range.includes("[diff]")) {
result.push({
operation: "DELETE",
text: `${range.replace(/\[diff\].+?\[\/diff\]/gs, "").replace(/\[diff\].+?/gs, "")}`,
text: `${range.replace(/\[diff\].+?\[\/diff\]/gs, "").replace(/\[diff\].+/gs, "")}`,
});
result.push({
operation: "DIFFERENT",
text: `[change]${range.replace(/\[delete\].+?\[\/delete\]/gs, "").replace(/.+?\[\/delete\]/gs, "")}`,
subOperation: "CHANGE",
text: `[change]${range.replace(/\[delete\].+?\[\/delete\]/gs, "").replace(/.+\[\/delete\]/gs, "")}`,
});
} else {
result.push({
Expand Down Expand Up @@ -337,10 +339,14 @@ const Resolver = ({ title, contents }: PropsType) => {

const onClickJoinArr = async () => {
const str = std
.map((obj: LineObject) => {
.map((obj: LineObject, index) => {
if (
obj.operation !== "EMPTY" ||
(["DELETE", "DELETES"].includes(obj.operation) && obj.text === "")
obj.operation !== "EMPTY" &&
!(
["DELETE", "DELETES"].includes(obj.operation) &&
!(obj.text === "") &&
std[index + 1]?.subOperation === "CHANGE"
)
)
return obj.text;
})
Expand Down

0 comments on commit 937c61e

Please sign in to comment.