-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add :character-info command #4000
Conversation
Instead of a regular command which must be bound to a key, I think this would be appropriate as a typable command ( |
Got it switched over to a typable command. I've named it |
Maybe something a bit more descriptive like |
9159cbd
to
c3e2dfd
Compare
Rebased to fix conflicts. Let me know if I should write tests, otherwise it should be ready |
I think this is looking great 😀 You can add an integration test like so: // helix-term/tests/test/commands.rs
#[tokio::test(flavor = "multi_thread")]
async fn test_character_info() -> anyhow::Result<()> {
test_key_sequence(
&mut helpers::AppBuilder::new().build()?,
Some("ih<esc>h:char<ret>"),
Some(&|app| {
assert_eq!(r#""h" (U+0068) Dec 104 Hex 68"#, app.editor.get_status().unwrap().0);
}),
false,
)
.await?;
Ok(())
} (you will want to rebase on latest master first since there are recent changes to the integration testing harness) |
a55bf1f
to
d27436b
Compare
Thanks for the pointer on the tests. I added that and a few more cases to fully cover the possible output formats. |
@archseer, sorry for the ping, Oops too late there on my part 😅 |
Should I resolve the conflict? Looks like it's just accepting both the test I added & a couple new ones from |
Sorry for the delay! Looks good to me, just needs a rebase :) |
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
3d1acaa
to
c4ce96a
Compare
This is my take on Vim's get ascii (ga) / get utf8 (g8) command. This works on graphemes not characters, so it correctly handles things like emoji with skin tone modifiers or characters with combining diacritics.
I'm open to opinions on what the output should look like. Atm, it outputs the decimal value only for single byte characters in an ascii-compatible encoding. For UTF-8, it also prints the decoded codepoints. (The decoder is based on fasterthanlime's article since I could not find anything in std or already in helix, or on crates.io for that matter, and it's pretty concise).
"a" (U+0061) Dec 97 Hex 61
"a" Dec 97 Hex 61
"\n" (U+000a) Dec 10 Hex 0a
"\r\n" (U+000d U+000a) Hex 0d + 0a
"é" (U+00e9) Hex c3 a9
"é" Hex e9
"ë" (U+0065 U+0308) Hex 65 + cc 88
"👍🏽" (U+1f44d U+1f3fd) Hex f0 9f 91 8d + f0 9f 8f bd
Remaining tasks:
Debug
formatting of character with something more appropriate.Debug
handles escaping non-printable & whitespace characters, but it also escapes the combining diaeresis on the ë…\0
,\t
,\n
, and\r
I'm not familiar with the codebase, so let me know if there's anything that could be more idiomatic. It does not have any tests yet, but it looks like most commands don't?
closes #3885