Completions: do not show directory file size.

Try to shorten these, too.
This commit is contained in:
Aaron Gyes 2021-11-04 04:05:12 -07:00
parent 6a7ba7921a
commit 40dcfaa90a
2 changed files with 27 additions and 26 deletions

View File

@ -25,33 +25,9 @@
#include "path.h"
#include "reader.h"
#include "wcstringutil.h"
#include "wildcard.h"
#include "wutil.h" // IWYU pragma: keep
/// Description for generic executable.
#define COMPLETE_EXEC_DESC _(L"Executable")
/// Description for link to executable.
#define COMPLETE_EXEC_LINK_DESC _(L"Executable link")
/// Description for regular file.
#define COMPLETE_FILE_DESC _(L"File")
/// Description for character device.
#define COMPLETE_CHAR_DESC _(L"Character device")
/// Description for block device.
#define COMPLETE_BLOCK_DESC _(L"Block device")
/// Description for fifo buffer.
#define COMPLETE_FIFO_DESC _(L"Fifo")
/// Description for symlink.
#define COMPLETE_SYMLINK_DESC _(L"Symbolic link")
/// Description for symlink.
#define COMPLETE_DIRECTORY_SYMLINK_DESC _(L"Symbolic link to directory")
/// Description for Rotten symlink.
#define COMPLETE_ROTTEN_SYMLINK_DESC _(L"Rotten symbolic link")
/// Description for symlink loop.
#define COMPLETE_LOOP_SYMLINK_DESC _(L"Symbolic link loop")
/// Description for socket files.
#define COMPLETE_SOCKET_DESC _(L"Socket")
/// Description for directories.
#define COMPLETE_DIRECTORY_DESC _(L"Directory")
/// Finds an internal (ANY_STRING, etc.) style wildcard, or wcstring::npos.
static size_t wildcard_find(const wchar_t *wc) {
for (size_t i = 0; wc[i] != L'\0'; i++) {
@ -511,7 +487,7 @@ static bool wildcard_test_flags_then_complete(const wcstring &filepath, const wc
if (expand_flags & expand_flag::gen_descriptions) {
desc = file_get_desc(lstat_res, lstat_buf, stat_res, stat_buf, stat_errno);
if (file_size >= 0) {
if (!is_directory && file_size >= 0) {
if (!desc.empty()) desc.append(L", ");
desc.append(format_size(file_size));
}

View File

@ -9,6 +9,31 @@
#include "complete.h"
#include "expand.h"
/// Description for generic executable.
#define COMPLETE_EXEC_DESC _(L"executable")
/// Description for link to executable.
#define COMPLETE_EXEC_LINK_DESC _(L"executable link")
/// Description for character device.
#define COMPLETE_CHAR_DESC _(L"char device")
/// Description for block device.
#define COMPLETE_BLOCK_DESC _(L"block device")
/// Description for fifo buffer.
#define COMPLETE_FIFO_DESC _(L"fifo")
/// Description for fifo buffer.
#define COMPLETE_FILE_DESC _(L"file")
/// Description for symlink.
#define COMPLETE_SYMLINK_DESC _(L"symlink")
/// Description for symlink.
#define COMPLETE_DIRECTORY_SYMLINK_DESC _(L"dir symlink")
/// Description for Rotten symlink.
#define COMPLETE_ROTTEN_SYMLINK_DESC _(L"rotten symlink")
/// Description for symlink loop.
#define COMPLETE_LOOP_SYMLINK_DESC _(L"symlink loop")
/// Description for socket files.
#define COMPLETE_SOCKET_DESC _(L"socket")
/// Description for directories.
#define COMPLETE_DIRECTORY_DESC _(L"directory")
// Enumeration of all wildcard types.
enum {
/// Character representing any character except '/' (slash).