From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 20764 invoked from network); 27 Aug 2023 11:39:25 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Aug 2023 11:39:25 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1693136365; b=bSbVgdNtodBbgAVeCqCR03d27fK62xn8HTvmkbP2TntMxVFEC2zdMMQLEyLxYoVzp6DOUdE0xf fctgiCcPFhR7zYSHnT/sX8um8a2jtOpcLT3KbhaB1KW/YPwDBusLWbkqVGQ6Ddmqms5Qrr6GAN Rk4GyME0qInCGPpp4U9Z7XS3AafBHSIez4hUtiC9wd0Fm9Y2U1HGXYp9YnRfV3e9vL5pj5NIb6 UWCl1zpD2DQSduzfWju7UN8orQXjl0kpU7zP4LRZZlJefZyUPPtL0g4yCDZBxmjmD/FSYJhJKx 9u2q1CxRGjKRKTB0ycwhp+oYjo8sCfu/V6cjnn/iASJOlQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-4322.protonmail.ch) smtp.remote-ip=185.70.43.22; dkim=pass header.d=protonmail.com header.s=protonmail3 header.a=rsa-sha256; dmarc=pass header.from=protonmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1693136365; bh=S3xcj1HOwimXw7vWw5slVR9NpS/SI9PGSxL0alhPVSs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version: References:In-Reply-To:Message-ID:Subject:Cc:From:To:DKIM-Signature:Date: DKIM-Signature; b=gh8VhNciRe83gyVBLY49fMUuNhr1x7FuXJD4gy6ZiyQHKZvMneiKr/mbHU4dVvoq5BhtqzzK6H +quWryPThKTFivMkzwAL+lsZ+OfS2e1DbUHBCorHO9tJV6lQTBEKJtux9D9Qa+DlNEQui4gCUr EE4pzzlgkQLyhba3hJn9VtFHNU/LX8dVWxD/vguwRZu/CLWpbaGDrvXmhsToTCEHgisvjUTbzE 4SjvAD/TeAtk95Ibahj6C7O/xqdIMlXQyqbAWRimt8bgc3FYo7v05N7ylL1SYCFuc94WQcjgg/ EOy3OMUiWrV0vIqzCTsZvNTlx2p4xb6wAFLgtXOIQMvsPA==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Subject:Cc:From: To:Date:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=I+TikXIt0l+CtvQTDOcZKiBB42ZdZj/h5g88hLT921U=; b=py/VYPg0TEY1lBg/vsppc87mAp gEmWGeJGKAmG1MOngFyUAl1RIILTqw028xf0si8SrS84AZGjoTH07ok6LDGILYFqrVd3pzObRvdvQ 2baxcdMWs+oGcK0Cd406SZuXPC5ciXn0oHVWEo9eRdK8iU6X0xoQEUmta48KamMoj0Mbapgv/SNZl r4A5bgbvoael8s9WoCXhuvvAjmDrqFRGFZIrFLkIRxWVK5eq/oBLgTNd5vankEeg2JscMLTQfkoAB 7H8rwmzn/fjjGQECSxmJflYz2bGrY1Gn7fDIIWoDdVB/wFBFimf3HODQfm+EuD/Z0RgSdqL6lTGzC HMfzW6Kg==; Received: by zero.zsh.org with local id 1qaE72-000MeJ-1k; Sun, 27 Aug 2023 11:39:24 +0000 Authentication-Results: zsh.org; iprev=pass (mail-4322.protonmail.ch) smtp.remote-ip=185.70.43.22; dkim=pass header.d=protonmail.com header.s=protonmail3 header.a=rsa-sha256; dmarc=pass header.from=protonmail.com; arc=none Received: from mail-4322.protonmail.ch ([185.70.43.22]:56255) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1qaE6i-000MLJ-AW; Sun, 27 Aug 2023 11:39:05 +0000 Date: Sun, 27 Aug 2023 11:38:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1693136343; x=1693395543; bh=I+TikXIt0l+CtvQTDOcZKiBB42ZdZj/h5g88hLT921U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=Sexn2ijuAQ7JkMXQDkxQHnXc8467uEDZ+nouMjd+3Jrae3hi4T+yTFlm9lq86MATF lwxmGwQP9mxk9Do/rE+NTgkbRbRQKXzn3PUWjAiKitpqRBL1rq5ZCLUWKCldI/dUah LxUgRTOk18kxuTyB1zjBRB4XdQ/CyXEx6yPCFzygBo/CH3PaFR2KAFJdAnSNMn4+Co BiHbifGCrjugjnjNX1Ed6qcAbjW2hvt1BzoC4aN3jBGOsQLep2yL5kd8wSqedW7Bll Sf7mO5ihzGLbl+2y+byNZFnigpoY0QmE1TVdgstkZ1bIksLUEpMjHh33Jmyf2+z/DE 98x51RpNGh5RA== To: Bart Schaefer From: Christoffer Lundell Cc: "zsh-workers@zsh.org" Subject: Re: [PATCH] Enable linewise edit-command when in visual-line Message-ID: <4g4xybTBXMIZ-p6C7Q9AQ9xx9GoUjTCQseIGsIonYhIy7H6QLFgJdIuGIisUIAaNZX8zEBXGtzPx80I_BLUpZr3QD_U_8ZweNj7e_jGBBBI=@protonmail.com> In-Reply-To: References: Feedback-ID: 3930316:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Seq: 52101 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: Thank you for your fast response, I did a bit of testing and have a couple uncertainties that I hope you can assist me with. > > > > + offset_right=3D${(SB)${BUFFER[mark_right+1,-1]}#$'\n'} > > >=20 > > > This I'm not sure of -- why mark_right+1 ? > >=20 > > This is because CURSOR and MARK are 0-indexed, according to zshzle(1). >=20 > They're 0-based because position 0 represents an empty line, the > non-character before $LBUFFER. The BUFFER and LBUFFER arrays > themselves are still 1-indexed (unless you're crazed enough to be > using zle with ksharrays). > BUFFER[CURSOR] is always the character to the left of the visible > cursor position. To make this work, CURSOR is decremented when > entering vicmd mode (unless it's already zero), but that doesn't > change MARK. >=20 > So ... I think this means that in vi-cmd-mode it is necessary to use > CURSOR+1 when MARK <=3D CURSOR, but not MARK+1 when CURSOR < MARK? And > never add one when in emacs mode? >=20 This makes me think I am missing something, because even when setting bindk= ey -e in my .zshrc and entering visual-line-mode, a cursor/mark on column 1 on a = 2nd line to the right of the other cursor/mark never includes said 2nd line, de= spite it being visually highlighted. That is, while using the suggested: right=3D${${BUFFER[CURSOR,-1]}[(i)$nl]} for MARK <=3D CURSOR and right=3D${${BUFFER[MARK,-1]}[(i)$nl]} for CURSOR < MARK I had to use CURSOR+1 and MARK+1 from the lines above to fix that edge case= . Which does not wrongfully include the following line when the cursor to the= far right of the first line in emacs mode, as might be expected. > > lbuffer=3D$lbuffer[++left,-1] >=20 > That's equivalent to lbuffer=3D when left=3D$CURSOR because by definition > everything after LBUFFER[CURSOR] is empty (and lbuffer=3D$LBUFFER at > that point). I believe ((right-left =3D=3D left+1)) when right=3D$CURSOR, > so should be a no-op compared to the original ((REGION_HIGHLIGHT =3D=3D > 1)) case. Disagree? You are right in that lbuffer=3D is equivalent for left=3D$CURSOR, however lbuffer[right-left,-1]=3D leaves the leading part of $lbuffer intact even i= f the visual selection does not start at the beginning of $BUFFER. And as I understand, $lbuffer is supposed to represent only the highlighted text bef= ore the cursor, to later figure out cursor positioning for the opened editor. The only thing that has been working consistently, and what fixes cursor positioning for me, is the previous: lbuffer=3D${lbuffer[++left,-1]} In both blocks for (( REGION_HIGHLIGHT =3D=3D 1 )) and (( REGION_HIGHLIGHT = =3D=3D 2 )) Please let me know if I am missing something. Christoffer