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

[Bug] Output window does not handle certain escape codes #404

Open
MrStevns opened this issue Aug 17, 2024 · 3 comments
Open

[Bug] Output window does not handle certain escape codes #404

MrStevns opened this issue Aug 17, 2024 · 3 comments

Comments

@MrStevns
Copy link

MrStevns commented Aug 17, 2024

Describe the bug
I have been using focus to work with odin projects which so far is a pleasant experience. Recently however, their test module got a major makeover which focus does not seem to be able to handle.

From the conversation with obiwanus on Discord, the issue stems from focus not expecting or being able to handle the escape codes being produced.

To Reproduce

  1. Create a odin project like so:
package rendering

import "core:log"
import "core:testing"

@test
example :: proc(t: ^testing.T)
{
    log.info("Debug test")
}
  1. Create a focus-config file so you can run the odin project and get the output like so:
    > odin test /path/to/project/
  2. Run the test project via the command modal in focus

Expected behavior

[INFO ] --- [2024-08-17 07:52:29] Starting test runner with 1 thread. Set with -define:ODIN_TEST_THREADS=n.
[INFO ] --- [2024-08-17 07:52:29] The random seed sent to every test is: 39114654177527. Set with -define:ODIN_TEST_RANDOM_SEED=n.
[INFO ] --- [2024-08-17 07:52:29] Memory tracking is enabled. Tests will log their memory usage if there's an issue.
[INFO ] --- [2024-08-17 07:52:29] < Final Mem/ Total Mem> <  Peak Mem> (#Free/Alloc) :: [package.test_name]
[INFO ] --- [2024-08-17 07:52:29] [rendering.odin:9:example()] Debug test
rendering  [|                       ]         1 :: [package done]

Finished 1 test in 270µs. The test was successful.

Actual behaviour

�[?25l�[?7lrendering  [�[90m|                       �[0m]    0/   1 :: �[90mexample�[0m
�[?7h1 thread                                 0/   1 :: total
�[2F�[J�]2;Odin test runner (0/1)�\�[?7lrendering  [�[33m|                       �[0m]    0/   1 :: �[33mexample�[0m
�[?7h1 thread                                 0/   1 :: total
�[2F�[J�]2;Odin test runner (1/1)�\�[?7lrendering  [�[32m|                       �[0m]         1 :: [package done]
�[?7h
�[?25h�[0m[INFO ] --- �[0m[2024-08-17 07:53:51] Starting test runner with 1 thread. Set with -define:ODIN_TEST_THREADS=n.
�[0m[INFO ] --- �[0m[2024-08-17 07:53:51] The random seed sent to every test is: 39368671393172. Set with -define:ODIN_TEST_RANDOM_SEED=n.
�[0m[INFO ] --- �[0m[2024-08-17 07:53:51] Memory tracking is enabled. Tests will log their memory usage if there's an issue.
�[0m[INFO ] --- �[0m[2024-08-17 07:53:51] < Final Mem/ Total Mem> <  Peak Mem> (#Free/Alloc) :: [package.test_name]
�[0m[INFO ] --- �[0m[2024-08-17 07:53:51] [rendering.odin:9:example()] Debug test
Finished 1 test in 151µs. The test was �[32msuccessful.�[0m

Screenshots
Expected:
image

Actual:
image

  • OS: macOS 12.7.2
  • Focus 0.6.0-5fd56ce
@MrStevns MrStevns changed the title Focus output does not handle certain escape codes [Bug] Focus output does not handle certain escape codes Aug 17, 2024
@MrStevns MrStevns changed the title [Bug] Focus output does not handle certain escape codes [Bug] Output window does not handle certain escape codes Aug 17, 2024
@focus-editor
Copy link
Owner

Thanks for logging the issue.

However since it's a recent addition to Odin maybe you could reach out to ginger Bill and tell him that escape codes should only be used when the output is being sent to a terminal?

Other programs are able to detect this and not send escape codes. E.g. Jai does this.

@MrStevns
Copy link
Author

Good point, I've created an issue there too. For reference: odin-lang/Odin#4100

@Feoramund
Copy link

Unless this program intends to parse ANSI SGR codes, both color and cursor motion, then this is strictly an issue with Odin's ability to detect the presence of a TTY.

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

3 participants