A few small changes to the "pub lish" confirmation UI.

* Don't collapse the root directory of a directory tree, since this is usually
  going to be a very heterogeneous set of files and directories.

* Indent "(N more...)" two fewer spaces. This makes it clearer at what level
  things are collapsed when it comes immediately after a directory. E.g.

      |-- dir
      |   '-- file
      | (6 more...)
      |-- other-dir

  vs

      |-- dir
      |   '-- file
      |   (6 more...)
      |-- other-dir

Review URL: https://codereview.chromium.org//11442068

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@16085 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
nweiz@google.com 2012-12-13 01:11:47 +00:00
parent 1125aff405
commit 899b1a7d1f
2 changed files with 56 additions and 25 deletions

View file

@ -50,7 +50,7 @@ import 'path.dart' as path;
/// |-- absolute_test.dart
/// |-- all_test.dart
/// |-- basename_test.dart
/// | (7 more...)
/// | (7 more...)
/// |-- path_windows_test.dart
/// |-- relative_test.dart
/// '-- split_test.dart
@ -109,7 +109,7 @@ void _draw(StringBuffer buffer, String prefix, bool isLast,
_draw(buffer, '$prefix$childPrefix', isLastChild, child, children[child]);
}
if (childNames.length <= 10) {
if (name == null || childNames.length <= 10) {
// Not too many, so show all the children.
for (var i = 0; i < childNames.length; i++) {
_drawChild(i == childNames.length - 1, childNames[i]);
@ -123,7 +123,7 @@ void _draw(StringBuffer buffer, String prefix, bool isLast,
// Elide the middle ones.
buffer.add(prefix);
buffer.add(_getPrefix(name == null, isLast));
buffer.add('| (${childNames.length - 6} more...)\n');
buffer.add('| (${childNames.length - 6} more...)\n');
// Show the last few.
_drawChild(false, childNames[childNames.length - 3]);

View file

@ -14,32 +14,59 @@ main() {
test('up to ten files in one directory are shown', () {
var files = [
"a.dart",
"b.dart",
"c.dart",
"d.dart",
"e.dart",
"f.dart",
"g.dart",
"h.dart",
"i.dart",
"j.dart"
"dir/a.dart",
"dir/b.dart",
"dir/c.dart",
"dir/d.dart",
"dir/e.dart",
"dir/f.dart",
"dir/g.dart",
"dir/h.dart",
"dir/i.dart",
"dir/j.dart"
];
expect(generateTree(files), equals("""
|-- a.dart
|-- b.dart
|-- c.dart
|-- d.dart
|-- e.dart
|-- f.dart
|-- g.dart
|-- h.dart
|-- i.dart
'-- j.dart
'-- dir
|-- a.dart
|-- b.dart
|-- c.dart
|-- d.dart
|-- e.dart
|-- f.dart
|-- g.dart
|-- h.dart
|-- i.dart
'-- j.dart
"""));
});
test('files are elided if there are more than ten', () {
var files = [
"dir/a.dart",
"dir/b.dart",
"dir/c.dart",
"dir/d.dart",
"dir/e.dart",
"dir/f.dart",
"dir/g.dart",
"dir/h.dart",
"dir/i.dart",
"dir/j.dart",
"dir/k.dart"
];
expect(generateTree(files), equals("""
'-- dir
|-- a.dart
|-- b.dart
|-- c.dart
| (5 more...)
|-- i.dart
|-- j.dart
'-- k.dart
"""));
});
test('files are not elided at the top level', () {
var files = [
"a.dart",
"b.dart",
@ -57,7 +84,11 @@ main() {
|-- a.dart
|-- b.dart
|-- c.dart
| (5 more...)
|-- d.dart
|-- e.dart
|-- f.dart
|-- g.dart
|-- h.dart
|-- i.dart
|-- j.dart
'-- k.dart
@ -105,7 +136,7 @@ main() {
|-- absolute_test.dart
|-- all_test.dart
|-- basename_test.dart
| (7 more...)
| (7 more...)
|-- path_windows_test.dart
|-- relative_test.dart
'-- split_test.dart