trunk8 icon indicating copy to clipboard operation
trunk8 copied to clipboard

Option to snip at word boundary

Open slowernet opened this issue 12 years ago • 8 comments

Would be a useful feature. Thanks.

slowernet avatar Aug 03 '12 15:08 slowernet

+1 truncate by word boundary would be great!

ggarnier avatar Sep 04 '12 21:09 ggarnier

Wondering about the performance hits this may incur.

The current method to find the best truncation is a modified binary search. So at worst, the search takes O(lg(n)).

The way I'm thinking to implement this would be to binary search as usual, but scan the string left or right (depending on the side setting) until the cut is made on a word boundary. This would be O(n) because you scan after finding the optimal cut.

Can this be faster?

rviscomi avatar Sep 04 '12 22:09 rviscomi

Maybe you could let word boundary as optional, and keep the current search method when word boundary is disabled. That way, the performance would remain unaffected on the default case.

ggarnier avatar Sep 04 '12 22:09 ggarnier

Yeah, I agree it'd be better to make this opt-in.

Curious if it can be made just as fast as the default functionality.

rviscomi avatar Sep 04 '12 22:09 rviscomi

Hi, are you planning to implement this enhancement? Thanks!

afarriaga avatar Apr 25 '13 16:04 afarriaga

@afarriaga This is high on my list for trunk8 but I don't have the time. Pull requests are welcome!

rviscomi avatar Apr 28 '13 01:04 rviscomi

+1 for this option.

realrandal avatar May 09 '13 05:05 realrandal

+1 for this option and a 'trunkOnWord' ;)

ric-h avatar Jun 22 '13 13:06 ric-h