Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncated aligned string #46

Open
zhtmalxh opened this issue Nov 27, 2024 · 1 comment
Open

Truncated aligned string #46

zhtmalxh opened this issue Nov 27, 2024 · 1 comment
Assignees

Comments

@zhtmalxh
Copy link

Host Environment

  • Host: x64-windows
  • Compiler: MSVC 19.42.34433.0 (but same result even with VS2019)

To Reproduce
add left or right alignment in sandbox.cpp, for example:

console->set_pattern(".red([%T] [:<10%n]) .dark_green([%l]): .cyan(%v) TEXT");

Expected
[18:58:48] [CONSOLE ] [critical]: First critical message TEXT
(4 white space after console)

Observed
[18:58:48] [ONSOLE ] [critical]: First critical message TEXT
(3 white space after console and first character eliminated)

Possible error
I just started looking at this project, I know very little about it but if I break this block in two:

const std::string_view aligned{ alignment_formatter::align(
	pattern.substr(flag_pos + flag_size, to_align_size), 
	alignment_flag_info.width, 
	alignment_flag_info.fill_char, 
	alignment_flag_info.side
) };

from ...\lwlog\src\details\pattern\alignment_formatter.cpp getting this:

auto s = alignment_formatter::align(
  pattern.substr(flag_pos + flag_size, to_align_size),
  alignment_flag_info.width,
  alignment_flag_info.fill_char,
  alignment_flag_info.side
);

const std::string_view aligned{ s };

the expected result is correct.

@ChristianPanov
Copy link
Owner

ChristianPanov commented Nov 27, 2024

Thank you for opening the issue, I might have an idea at what point it stopped working correctly. I'll be busy with work the following days but I'll try to close it by the end of the week.

If you have any questions regarding the library or you spot some other kind of problem, feel free to write

Thanks

NOTE: When you specify an alignment of 10 units, given the value of the aligned attribute is "CONSOLE"(7 characters), the expected remaining white space should be 3 units, not 4, as you've described it as expected behaviour

@ChristianPanov ChristianPanov self-assigned this Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants