curran / curran/google-diff-match-patch

xIndex for instertion after location

Aperta
#101 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
auto-migrated Priority-Medium Type-Defect
Lingua principale
Python
Stelle
17
Fork
2
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

```
Hello!

When you are looking for the end position while something was added to the end
of the text, then result will be the end of the new text. Here is a test:
assertEquals(3, dmp.diff_xIndex([[DIFF_EQUAL, 'foo'], [DIFF_INSERT, 'bar']], 3));
The result will be 6.

My understanding of locations within text is that it's just like a cursor. For
example:
|foo - position 0
f|oo - position 1
fo|o - position 2
foo| - position 3

I've tried to fix it by myself and have changed > comparison to >= in
https://code.google.com/p/google-diff-match-patch/source/browse/trunk/javascript
/diff_match_patch_uncompressed.js#1199
but it's actually breaks the last test for patchApply, so I'm doubting about my
understanding of locations within text. So, can you make it clear what is that
location in xIndex method?

By the way, there is a small bug in the doc example for xIndex:
e.g. 'The cat' vs 'The big cat', 1->1, 5->8
There was 4 chars inserted ("big "), so 5 should became 9.
```

Original issue reported on code.google.com by `grigory.kalabin` on 29 Apr 2014 at 3:05

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da diff_xIndex in javascript/diff_match_patch_uncompressed.js e dal test di patchApply menzionato nel report. Confronta l’esempio di inserimento fornito con l’esempio della documentazione di xIndex, quindi stabilisci la semantica prevista della posizione senza compromettere il comportamento esistente di patchApply.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.