Fix C module to match Elisp behavior for last-line overflow handling
When is_last && ideal > line_width, the C module now correctly triggers force break logic, matching ekp--dp-cache-elisp behavior. This ensures consistent results between C module and pure Elisp paths. Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
This commit is contained in:
parent
b296de0928
commit
fee05f769d
1
_codeql_detected_source_root
Symbolic link
1
_codeql_detected_source_root
Symbolic link
@ -0,0 +1 @@
|
||||
./ekp_c
|
||||
@ -166,8 +166,10 @@ static void process_dp_range(void *arg)
|
||||
max_w += p->hyphen_width;
|
||||
}
|
||||
|
||||
/* Too long? */
|
||||
if (min_w > line_width) {
|
||||
/* Too long? Also handle is_last && ideal > line_width.
|
||||
* This matches Elisp's ekp--dp-cache-elisp which breaks when
|
||||
* content won't fit even at the end of a paragraph. */
|
||||
if (min_w > line_width || (is_last && ideal > line_width)) {
|
||||
/* Force break if nothing else found */
|
||||
if (k > 1 && work->demerits[k - 1] >= EKP_INFINITY) {
|
||||
int32_t rest = line_width - (p->ideal_prefix[k - 1] -
|
||||
@ -497,8 +499,10 @@ ekp_result_t *ekp_break_with_prefixes(
|
||||
max_w += hyphen_width;
|
||||
}
|
||||
|
||||
/* Too long? Force break at k-1 if no valid break found yet */
|
||||
if (min_w > line_width) {
|
||||
/* Too long? Also handle is_last && ideal > line_width.
|
||||
* This matches Elisp's ekp--dp-cache-elisp which breaks when
|
||||
* content won't fit even at the end of a paragraph. */
|
||||
if (min_w > line_width || (is_last && ideal > line_width)) {
|
||||
if (k > i + 1 && demerits[k - 1] >= EKP_INFINITY) {
|
||||
/* Force break at previous position with high penalty */
|
||||
int32_t prev_ideal = ideal_prefix[k - 1] - ideal_prefix[i] - lead_ideal;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user