Closed carlosmgilp closed 3 years ago
Hi @carlosmgilp , Partial diff doesn't know if those lines are semantically the same, as it only does text comparison.
However, if just ignoring the line break difference does the job, you can use partialDiff.preComparisonTextNormalizationRules
with something like this:
"partialDiff.preComparisonTextNormalizationRules": [
{
"name": "Ignore line breaks",
"match": "\n+",
"replaceWith": " "
}
]
Hello @ryu1kn how are you. Thanks for your answer.
I don't really understand how the rule works.
Could you explain to me what I'm doing wrong. Thank you in advance.
Ah, in your first comment, all lines didn't have indentations. I've updated it to use a code block to keep the indentations.
With the leading indentation, the regex I posted above doesn't work. Something like this would do "match": " *\n +"
. The comparison result should look like this (no difference).
Hi @ryu1kn , thanks again for your time to help me.
But it doesn't work for me.
Save the new rule.
Verify that it was active.
I made the previous selection. Then select the text to compare. And this is the result it gives me.
In what you can help me, I appreciate it.
Are you using Windows? Is your line ending character CRLF
but not LF
? In which case, the regex needs to be "match": " *\r\n +"
Hello Brother how are you. Excuse me for not specifying the operating system. I work with windows. Thank you. Now if it works very well. I don't understand why it puts all the code on one line. If that could be improved in the future, it would be much better. If it were shown as the example image it would be spectacular.
Thank you very much for helping me, for your time and dedication. Greetings and many successes.
@carlosmgilp It puts all the code on one line because the below normalisation rule instructs to replace strings that match regex *\r\n +
to a single space character. We can improve this normalisation rule but as the extension doesn't know the language syntax (it doesn't have a lisp parser), it would be limited.
"partialDiff.preComparisonTextNormalizationRules": [
{
"name": "Ignore line breaks",
"match": " *\r\n +",
"replaceWith": " "
}
]
I'm closing this...
Is there any way that I can compare two pieces of code, but it is only the code, not what line it is on. The code is from Autocad autolisp extension. I have two code snippets
Both are the same, it only changes that one line is on another, but the code still works. Comparing the selections shows me a difference, but there should be no difference because the code is the same. How can I improve this. Thanks.