coc-pyright icon indicating copy to clipboard operation
coc-pyright copied to clipboard

Linting completely breaks when asked to confim a substitution with inccommand turned on.

Open avalonv opened this issue 2 years ago • 8 comments

Starting a substitution with :%s:::c while inccommand is set to either split or nosplit completely messes up linting and highlighting. Replacements don't have to actually be confirmed, simply initiating a substitute command causes problems.

Replacing items without the c flag in the substitution, or with set inccommand= behaves as expected.

Video which demonstrates the issue: https://imgur.com/a/WOa4N6W

Screenshot: image

What's the output of :CocCommand pyright.version coc-pyright 1.1.265 with Pyright 1.1.265

What's the output of :CocCommand workspace.showOutput Pyright

Workspace: /home/satsu/Documents/cursewordle
Using python from /usr/bin/python

[Info  - 8:32:23 PM] Pyright language server 1.1.265 starting
[Info  - 8:32:23 PM] Server root directory: /home/satsu/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
[Info  - 8:32:23 PM] Starting service instance "cursewordle"
[Info  - 8:32:23 PM] No configuration file found.
[Info  - 8:32:23 PM] No pyproject.toml file found.
[Info  - 8:32:23 PM] Setting pythonPath for service "cursewordle": "/usr/bin/python"
[Warn  - 8:32:23 PM] stubPath /home/satsu/Documents/cursewordle/typings is not a valid directory.
[Info  - 8:32:23 PM] Assuming Python version 3.10
[Info  - 8:32:23 PM] Assuming Python platform Linux
[Info  - 8:32:23 PM] Searching for source files
[Info  - 8:32:23 PM] Found 6 source files

avalonv avatar Sep 01 '22 23:09 avalonv

I suspect this could be an issue with inccommand's implementation more broadly, but I'm not entirely sure how to test that.

Let me know if you need more logs

avalonv avatar Sep 01 '22 23:09 avalonv

inccommand is nosplit by default, check :h inccommand. I can't reproduce your issue.

fannheyward avatar Sep 02 '22 02:09 fannheyward

inccommand is nosplit by default, check :h inccommand. I can't reproduce your issue.

You're right, I just assumed it was off by default.

Updated title, seems to be specifically triggered by the confirm flag in a substitution command.

I tried with a minimal init.vim with just the following, largely identical to the standard coc-config:

https://gist.github.com/avalonv/a01f6a0feec2dd287350d3ebd72a70c7

Typing :%s:::c in a python file will mess up linting regardless of whether enter or <esc> is subsequently typed. No substitutions have to take place for this to occur.

avalonv avatar Sep 02 '22 09:09 avalonv

@fannheyward have you been able to replicate this? I tested it in another machine but I'm still wondering if it might have something to do with my configuration.

avalonv avatar Sep 03 '22 20:09 avalonv

Can't reproduce this.

fannheyward avatar Sep 08 '22 07:09 fannheyward

Test code:

def foo(bar: int = None):
    print(bar)
  1. :set inccommand=nosplit
  2. search bar
  3. :%s::c
截屏2022-09-15 16 17 57

<cr> to accept, or <esc> to roll back.

fannheyward avatar Sep 15 '22 08:09 fannheyward

Hi, the example doesn't really apply.

I'm not trying to replace bar with c, c in this case is the confirm flag for the substitute command, not the replacement string.

The command should be :%s:::c (three : in the middle)

Made another video which should be clearer to read: https://imgur.com/a/aBsa82E

In this video, I slightly edited your code, but otherwise everything is the same.

In the first example, running set inccomand= then :%s:::c, shows the expected behaviour, it asks me to confirm each instance of bar, I press n for each prompt and no words are actually replaced.

In the second example, with set inccommand=nosplit, linting errors appear, pyright thinks bar in the first and third line are missing, even though they haven't actually changed.

avalonv avatar Sep 15 '22 10:09 avalonv

Sorry for the ::: issue, I made it wrong with two sign.

Here's my test.

mini.vim

set nocompatible
set runtimepath^=/Users/fannheyward/.local/share/nvim/plugged/coc.nvim
filetype plugin indent on
syntax on

set runtimepath^=~/src/coc-pyright

test code foo.py:

def foo(bar: int = None):
    bar = 1

steps:

  1. nvim -u mini.vim foo.py
  2. search bar
  3. :%s:::c, without <cr> to confirm
截屏2022-09-15 18 42 39

two bar are removed. <cr> to confirm:

截屏2022-09-15 18 42 57

press n twice, no errors.

:set inccommand=nosplit, and :%s:::c again, press <cr> to confirm and n twice, no errors.

fannheyward avatar Sep 15 '22 10:09 fannheyward