mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug
- Hyphenation is not needed when words are split with commas. - Unit test added.
This commit is contained in:
parent
d6ce938c4a
commit
4baaf52610
3 changed files with 77 additions and 1 deletions
|
@ -23,6 +23,9 @@ Features
|
|||
+ Fixed the mechanism used for selecting translations (thanks to Fidel Mato).
|
||||
|
||||
Bugs
|
||||
+ Improved hyphenation by splitting on commas (even if no whitespace after).
|
||||
Leads to better output of, for example, 'task show', where comma-separated
|
||||
lists are common.
|
||||
+ Fixed bug #1031, which kept expanding aliases after the '--' operator (thanks
|
||||
to Jim B).
|
||||
+ Fixed bug #1038, which prints blank lines with bulk changes and when the
|
||||
|
|
16
src/text.cpp
16
src/text.cpp
|
@ -300,6 +300,7 @@ int longestLine (const std::string& input)
|
|||
// - EOS
|
||||
// - \n
|
||||
// - last space before 'length' characters
|
||||
// - last comma before 'length' characters, even if not followed by a space
|
||||
// - first 'length' characters
|
||||
void extractLine (
|
||||
std::string& text,
|
||||
|
@ -310,6 +311,7 @@ void extractLine (
|
|||
std::string::size_type bytes = 0;
|
||||
std::string::size_type previous = std::string::npos;
|
||||
std::string::size_type last_space = std::string::npos;
|
||||
std::string::size_type last_comma = std::string::npos;
|
||||
int character;
|
||||
int width = 0;
|
||||
while (width < length)
|
||||
|
@ -321,6 +323,10 @@ void extractLine (
|
|||
if (character == ' ')
|
||||
last_space = previous;
|
||||
|
||||
// Record last seen comma.
|
||||
if (character == ',')
|
||||
last_comma = previous;
|
||||
|
||||
// Newline is an early break point.
|
||||
if (character == '\n')
|
||||
{
|
||||
|
@ -371,7 +377,15 @@ void extractLine (
|
|||
return;
|
||||
}
|
||||
|
||||
// Case where a word needs to be split, and there is no last_space.
|
||||
if (last_comma != std::string::npos)
|
||||
{
|
||||
line = text.substr (0, last_comma + 1);
|
||||
text = text.substr (last_comma + 1);
|
||||
return;
|
||||
}
|
||||
|
||||
// Case where a word needs to be split, and there is no last_space
|
||||
// or last_comma.
|
||||
// Hyphenation becomes the issue.
|
||||
// 012345
|
||||
// |fiftee|n
|
||||
|
|
59
test/hyphenate.t
Executable file
59
test/hyphenate.t
Executable file
|
@ -0,0 +1,59 @@
|
|||
#! /usr/bin/env perl
|
||||
################################################################################
|
||||
## taskwarrior - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006-2012, Paul Beckingham, Federico Hernandez.
|
||||
##
|
||||
## Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
## of this software and associated documentation files (the "Software"), to deal
|
||||
## in the Software without restriction, including without limitation the rights
|
||||
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
## copies of the Software, and to permit persons to whom the Software is
|
||||
## furnished to do so, subject to the following conditions:
|
||||
##
|
||||
## The above copyright notice and this permission notice shall be included
|
||||
## in all copies or substantial portions of the Software.
|
||||
##
|
||||
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
## SOFTWARE.
|
||||
##
|
||||
## http://www.opensource.org/licenses/mit-license.php
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 3;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bug.rc')
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
print $fh "confirmation=no\n";
|
||||
print $fh "defaultwidth=50\n";
|
||||
print $fh "detection=off\n";
|
||||
close $fh;
|
||||
ok (-r 'bug.rc', 'Created bug.rc');
|
||||
}
|
||||
|
||||
# Split on comma instead of hyphenating
|
||||
|
||||
my $output = qx{../src/task rc:bug.rc show report.next.columns | tail -n +4 2>&1};
|
||||
unlike ($output, qr/-/, 'split on comma for comma-separated lists');
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc);
|
||||
ok (! -r 'pending.data' &&
|
||||
! -r 'completed.data' &&
|
||||
! -r 'undo.data' &&
|
||||
! -r 'backlog.data' &&
|
||||
! -r 'synch.key' &&
|
||||
! -r 'bug.rc', 'Cleanup');
|
||||
|
||||
exit 0;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue