Skip to content

Commit

Permalink
Remove unicode-width dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
WGUNDERWOOD committed Oct 16, 2024
1 parent a94522e commit eebc708
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 22 deletions.
7 changes: 0 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ lazy_static = "1.5.0"
log = "0.4.22"
regex = "1.11.0"
similar = "2.6.0"
unicode-width = "0.2.0"

[profile.release]
codegen-units = 1
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ tex-fmt is over a thousand times faster than latexindent.

| **Files** | **Lines** | **Size** | **tex-fmt** | **latexindent** | **latexindent -m** |
| --- | --- | --- | --- | --- | --- |
| 49 | 94k | 3.5M | **0.055s** | 99s [x1800] | 132s [x2400] |
| 49 | 94k | 3.5M | **0.052s** | 99s [x1904] | 132s [x2538] |

## Contribution

Expand Down
15 changes: 2 additions & 13 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::comments::*;
use crate::format::*;
use crate::logging::*;
use log::Level::{Trace, Warn};
use unicode_width::UnicodeWidthChar;

/// String slice to start wrapped text lines
pub const TEXT_LINE_START: &str = "";
Expand All @@ -14,16 +13,7 @@ pub const COMMENT_LINE_START: &str = "% ";

/// Check if a line needs wrapping
pub fn needs_wrap(line: &str, indent_length: usize, args: &Cli) -> bool {
!args.keep
&& ({
let mut line_length = 0;
for c in line.chars() {
line_length +=
c.width().expect("Why control character in text?");
}
line_length
} + indent_length
> args.wrap.into())
!args.keep && (line.chars().count() + indent_length > args.wrap.into())
}

/// Find the best place to break a long line
Expand All @@ -42,8 +32,7 @@ fn find_wrap_point(

// Return *byte* index rather than *char* index.
for (i, c) in line.char_indices() {
line_width += c.width().expect("No control characters in text.");

line_width += 1;
if line_width > wrap_boundary && wrap_point.is_some() {
break;
}
Expand Down

0 comments on commit eebc708

Please sign in to comment.