Closed GoogleCodeExporter closed 9 years ago
That should be:
blip.at(len(blip)-1).insert(element.Button('bob', 'fred'))
because indices into the blip are 0-based.
Original comment by joe.gregorio@gmail.com
on 7 May 2010 at 12:41
blip.at(len(blip)) is the position on the right side of the last character, so
should do append, which it doesn't
blip.at(len(blip)-1) is the left side of the last character, so should insert
just before the last character, which it does
Please consider the following code and the running of that code:
https://wave.google.com/wave/#minimized:search,restored:wave:googlewave.com!w%25
2B7U3OtCPyH.2,restored:wave:googlewave.com!w%252B7U
3OtCPyL.1
The code is
blip.append("test")
blip.at(len(blip)-1).insert('foo')
blip.append("\ntest")
blip.at(len(blip)).insert("bar")
The result is
tesfoot
test
with no "bar" appearing because of a crash.
The expected result would be
tesfoot
testbar
My use case is that I want to add something after finding a piece of text in a
wave. I don't want to have to check whether the
thing that has been entered is at the last position in the wave and then switch
to appending instead. I think I haven't screwed up
indexes.
Original comment by duncan.hawthorne
on 7 May 2010 at 10:15
Original comment by pamela.fox
on 7 May 2010 at 11:14
OK, that's because insert means insert before the position. There is an
insert_after
operation which does what you want. So revising the code, it
should be:
blip.at(len(blip)-1).insert_after(element.Button('bob', 'fred'))
Does that solve the problem for you?
Original comment by joe.gregorio@gmail.com
on 13 May 2010 at 12:45
Closing for now, please reopen if that doesn't work for you.
Original comment by joe.gregorio@gmail.com
on 27 May 2010 at 12:28
Original issue reported on code.google.com by
duncan.hawthorne
on 24 Apr 2010 at 11:29