From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#28936: move_it_in_display_line_to returns MOVE_POS_MATCH_OR_ZV before ZV Date: Sat, 21 Oct 2017 22:14:39 -0700 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1508649318 10738 195.159.176.226 (22 Oct 2017 05:15:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 22 Oct 2017 05:15:18 +0000 (UTC) To: 28936@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Oct 22 07:15:11 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e68bK-000146-71 for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 07:15:07 +0200 Original-Received: from localhost ([::1]:60095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e68bP-00050t-Mf for geb-bug-gnu-emacs@m.gmane.org; Sun, 22 Oct 2017 01:15:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e68bJ-00050Y-Ir for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 01:15:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e68bG-0001T9-Cc for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 01:15:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46169) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e68bG-0001Sr-69 for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 01:15:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1e68bF-0007uV-QH for bug-gnu-emacs@gnu.org; Sun, 22 Oct 2017 01:15:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 22 Oct 2017 05:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28936 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 28936-submit@debbugs.gnu.org id=B28936.150864928530364 (code B ref 28936); Sun, 22 Oct 2017 05:15:01 +0000 Original-Received: (at 28936) by debbugs.gnu.org; 22 Oct 2017 05:14:45 +0000 Original-Received: from localhost ([127.0.0.1]:54850 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e68az-0007tg-Gg for submit@debbugs.gnu.org; Sun, 22 Oct 2017 01:14:45 -0400 Original-Received: from gateway30.websitewelcome.com ([192.185.192.34]:34129) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e68ax-0007tX-0U for 28936@debbugs.gnu.org; Sun, 22 Oct 2017 01:14:43 -0400 Original-Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 6232452FE for <28936@debbugs.gnu.org>; Sun, 22 Oct 2017 00:14:42 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id 68aueM4Y45b6T68aved28q; Sun, 22 Oct 2017 00:14:42 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=m4dW39vb7N5UJ4BcxhJkrLefty2g1K7owlPk2j8hKAg=; b=LwubBlR1qymD6M45DkSyx6D03Z PQvrSSjC2xiMgPlWzvsWTZdIHe7fnHH9VwZmNmR5BBCJQOOXp9hE6Wn2aumaijiJM/oxebPvTJ5kg mQeZ0Ew7kQsp5h4gMlXg41fcETd3k2fMK0E0Hq1IoZc4W6r3oWPl8O/DPxkhGqCisn4En3WTKyxdU nVkdaKnT5PNRMfEuEq0KFhQViLY/zjqOTOPZtAQ1ES351Ut6h6cP1twdUB3BXZHeCcAE6IRP/iMWG jTCN8ifqNTJ8HTXVNqr6OKAepRi9xVBFcfngVDNw7xCSHCxomWQUvvfgnusTeIRTbEt38YEcNJKSi S4fRYQXg==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:53887 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1e68au-0049Ps-Ju for 28936@debbugs.gnu.org; Sun, 22 Oct 2017 00:14:40 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - debbugs.gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Exim-ID: 1e68au-0049Ps-Ju X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private) [45.48.239.195]:53887 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:138838 Archived-At: Here is a second draft move_it_in_display_line_to_x, with compatibility for word-wrap and also horizontal scrolling the current line that erroneously returns MOVE_LINE_TRUNCATED when trying to reach a target X that is about 1,000 pixels from the beginning of the line. int move_it_in_display_line_to_x (struct window *w, struct it *it, int target_x) { struct it saved_it; void *saved_data = bidi_shelve_cache (); enum move_it_result rc = MOVE_X_REACHED; int new_x, prev_x; /* Advance straight to `it->first_visible_x` if IT is prior thereto. */ if (it->current_x < it->first_visible_x) move_it_in_display_line_to (it, ZV, it->first_visible_x, MOVE_TO_POS | MOVE_TO_X); /* When horizontal scrolling a long line that approach or exceed an `it.current.x` of approximately 1000, `rc` will erroneously return early as MOVE_LINE_TRUNCATED without pushing on forwards until it reaches the target_x. As a workaround, we ignore MOVE_LINE_TRUNCATED. It is uncertain whether this is a bug. */ while (it->current_x + it->pixel_width <= target_x && (rc == MOVE_X_REACHED || rc == MOVE_LINE_TRUNCATED || (it->line_wrap == WORD_WRAP && rc == MOVE_POS_MATCH_OR_ZV))) { SAVE_IT (saved_it, *it, saved_data); new_x = it->current_x + it->pixel_width; if (new_x == it->current_x) new_x++; rc = move_it_in_display_line_to (it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X); if (ITERATOR_AT_END_OF_LINE_P (it) || FETCH_BYTE (IT_BYTEPOS (*it)) == '\n' /* There is a bug in `move_it_in_display_line_to' such that it returns MOVE_POS_MATCH_OR_ZV before reaching ZV when the latter is at the end of the line: abcdefg[EOB]. The workaround is to add an extra check using IT_CHARPOS and comparing it to ZV. */ || (rc == MOVE_POS_MATCH_OR_ZV && IT_CHARPOS (*it) == ZV)) break; } /* When word-wrap is on, TO_X may lie past the end of a wrapped line. Then it->current is the character on the next line, so backtrack to the space before the wrap point. */ if (it->line_wrap == WORD_WRAP && rc == MOVE_LINE_CONTINUED) { prev_x = max (it->current_x - 1, 0); RESTORE_IT (it, &saved_it, saved_data); move_it_in_display_line_to (it, -1, prev_x, MOVE_TO_X); } bidi_unshelve_cache (saved_data, true); return rc; }