From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Platon Pronko Newsgroups: gmane.emacs.help Subject: Re: Moving point around empty overlays with 'after-text Date: Mon, 10 Apr 2023 09:52:54 +0800 Message-ID: References: <9b1654ec-1ac6-4936-860b-2d77dcc4dac7@app.fastmail.com> <28954f0d-205d-b322-4a43-cf4481d1266e@gmail.com> <3a1bb709-d00f-49b8-a2c5-d0ac5b6a82c4@app.fastmail.com> <22b315db-39eb-80b6-1a7c-127f5e703dc1@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4569"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 To: tomas@tuxteam.de, help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 10 03:53:43 2023 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1plgj0-000100-CU for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 10 Apr 2023 03:53:42 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1plgiQ-0003rR-Eu; Sun, 09 Apr 2023 21:53:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1plgiL-0003pt-SQ for help-gnu-emacs@gnu.org; Sun, 09 Apr 2023 21:53:01 -0400 Original-Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1plgiK-0004s8-5w for help-gnu-emacs@gnu.org; Sun, 09 Apr 2023 21:53:01 -0400 Original-Received: by mail-pl1-x62f.google.com with SMTP id m18so3473239plx.5 for ; Sun, 09 Apr 2023 18:52:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1681091578; x=1683683578; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=D9jMe+Y/bYFzyyU7cEI48OHl6ZnS4lyKG0U2UGyzSpc=; b=eisJ3Zgj2ga5lqizZJDrs4sxXidTJcTzM8Ix6sARcN8GKKwDrSFERzFv8086XV1uF0 F037/nOJRB2ns8dE55mYIZDUcLZWmgDptgooyNCiQfHIfip0pcHGZSdNC6zk1xv7Py/s PUrJcGzemIiU7u18Svl73LfeIPXFvAZVvJ+rCJ62cS5oRD3+hnQ9xuKkzoQbza8ckUWv iqNXJJsY7Y0cLMzExgqchSL6ncMek3ODWmH5tlkEhkCKE5LyIAmfbjhwEjAuhUlir4su bhoT3t0bMbe+QRusR2AWkFEVjlWjnQMnOqYGpsoSjuLehbVQMjebp1ogK2tPX2JyRAlZ zhgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681091578; x=1683683578; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=D9jMe+Y/bYFzyyU7cEI48OHl6ZnS4lyKG0U2UGyzSpc=; b=KqExu67i9dY08XvAyTE53/zd1BwYGgDl29FUPYWHhJZdW0KqX9p2bFr/NAQyMGbfha jYDHfAFDV4IpV7AWaDfUgPYQDFX5VTcbbHGS8I4mwU7IwIKiHq2334niB8X10AbQy1Ny xkbYPb6iHVKanHkMnnu03RKaBIq5c/hW5ZZaawdZEhKjvGfScBOKrWZLI1r8CzqzAUhe frxcC7gORLNHA6wCRC9pO2j8E94cV07aQxNI8dYkzkxruChfPYNEELJXxlImBFTq1O8z GnIq6ECMTu7xKQ526HyBVtO331L0TspO2ZhUlBoUMgX864plK4WsRb2+okItiVIdk6O1 pWHw== X-Gm-Message-State: AAQBX9dEcfx2aUcc2PxdHey9+v3xdJfuh0hFYb28Uuck3wPETlp3dFK2 BpXLOxOQPktl22Cxx8Yk0QLoVQThDse8/A== X-Google-Smtp-Source: AKy350a21oZ4PS6imbYQspP/8RNvYU0pskzOrtSiRpkL2IuQ2yD4S7N4CMPVH59aQ+Jfc4Et60enbQ== X-Received: by 2002:a17:903:4093:b0:19a:bbd0:c5cc with SMTP id z19-20020a170903409300b0019abbd0c5ccmr8917434plc.60.1681091578215; Sun, 09 Apr 2023 18:52:58 -0700 (PDT) Original-Received: from [192.170.1.133] ([103.24.106.35]) by smtp.gmail.com with ESMTPSA id f16-20020a170902ab9000b001a1fe40a8dasm6414234plr.262.2023.04.09.18.52.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 09 Apr 2023 18:52:57 -0700 (PDT) Content-Language: en-US In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::62f; envelope-from=platon7pronko@gmail.com; helo=mail-pl1-x62f.google.com X-Spam_score_int: -49 X-Spam_score: -5.0 X-Spam_bar: ----- X-Spam_report: (-5.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, NICE_REPLY_A=-2.888, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:143236 Archived-At: On 2023-04-09 22:49, tomas@tuxteam.de wrote: > On Sun, Apr 09, 2023 at 08:15:31PM +0800, Platon Pronko wrote: >> On 2023-04-09 07:06, Ash wrote: >>> Yeah, that's my message, hence why I was asking if I was missing something :) >>> >>> In some cases it makes sense to put the cursor after the overlay; for example, when invoking a function, the overlay can look like >>> >>> some_function({argument_name: }some_value) >>> >>> in which case you'd expect to be able to put the cursor after the overlay (to edit the value) and before (to add another argument to the list). Both cursor positions would correspond to the same location, but you're doing something different semantically. So I would expect to be able to type 'another_value, ' before the overlay and 'foo' after and get >>> >>> some_function(another_value, {argument_name: }foosome_value) >>> >>> and not >>> >>> some_function({argument_name: }another_value, foosome_value) >>> >>> In practice, I think for the existing overlays in rust-analyzer's inlay hints there's a 'preferred' cursor position (start for type annotations, end for param name annotations) where the user will want it 80% of the time, so it could set things up based on that. Might also investigate the nasty solution and see how clean I can get it and see if it's expensive CPU-wise. >>> >> >> I looked at what other IDE is doing (IDEA in my case). They indeed allow the cursor to be positioned both before and after the inlay, with added text appearing exactly as you described. >> >> I still think that doing this hack with "detect if the cursor moved exactly one position forward, tweak overlay, move it back" is horrible. It feels like it might be much better if this was handled at much lower level, not at the level of lsp-mode. > > What I don't understand is why the overlay doesn't cover the > whole argument value instead of sticking before it. Perhaps > this would ease some of the problems? > > Cheers Why should it? (maybe there's a confusion because of the words - what is being used here is technically a zero-width overlay, so it's not "overlaying" anything, it's probably better to call it "inlay") Anyway, even if you make this overlay to cover something it won't solve the problem - it still won't be possible to navigate the cursor to be before or after the hint. -- Best regards, Platon Pronko PGP 2A62D77A7A2CB94E