neoclide / coc-vetur

Vue language server extension for coc.nvim
219 stars 7 forks source link

Mark is lost after vue files are formated on save #77

Open mauchchhash opened 2 years ago

mauchchhash commented 2 years ago

My .vue files are formated when I save. The issue occurs when I set a mark on a line. When I save the file and it formats the codes, then the mark is lost and the nvim error says "E20: Mark is not set". I have disabled this extension and it then this issue doesn't occur anymore. So the issue is with this extension.

Steps to reproduce: 1) set a mark on a line in a .vue file. 2) change the format of the code a bit so it formats when you save. 3) Attempt to jump to your mark.

Thanks.

chemzqm commented 2 years ago

What's your CocInfo?

mauchchhash commented 2 years ago

@chemzqm My CocInfo:

versions

vim version: NVIM v0.6.1 node version: v16.13.2 coc.nvim version: 0.0.80-0428328f9a coc.nvim directory: /home/xxxxxx/.nvim/plugged/coc.nvim term: xterm-256color platform: linux

Log of coc.nvim

2022-04-09T07:48:04.118 INFO (pid:179478) [plugin] - coc.nvim initialized with node: v16.13.2 after 862ms 2022-04-09T07:48:06.493 INFO (pid:179478) [attach] - receive notification: showInfo []

mauchchhash commented 2 years ago

@chemzqm Hi just checking. Have you checked it out?

chemzqm commented 2 years ago

It's because vls send changes for all the lines:

[Trace - 8:35:01 PM] Received response 'textDocument/formatting - (1)' in 634ms.
Result: [
    {
        "range": {
            "start": {
                "line": 0,
                "character": 10
            },
            "end": {
                "line": 5,
                "character": 0
            }
        },
        "newText": "\n  <div id=\"app\">\n    <img alt=\"Vue logo\" src=\"./assets/logo.png\" />\n    <HelloWorld msg=\"Welcome to Your Vue.js + TypeScript App\" />\n  </div>\n"
    },
    {
        "range": {
            "start": {
                "line": 7,
                "character": 18
            },
            "end": {
                "line": 22,
                "character": 0
            }
        },
        "newText": "\nimport Vue from \"vue\";\nimport HelloWorld from \"./components/HelloWorld.vue\";\n\nexport default Vue.extend({\n  name: \"app\",\n  components: {\n    HelloWorld,\n  },\n  methods: {\n    wrong(): string {\n      return \"\";\n    },\n  },\n});\n"
    },
    {
        "range": {
            "start": {
                "line": 24,
                "character": 7
            },
            "end": {
                "line": 33,
                "character": 0
            }
        },
        "newText": "\n#app {\n  font-family: \"Avenir\", Helvetica, Arial, sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  text-align: center;\n  color: #2c3e50;\n  margin-top: 60px;\n}\n"
    }
]

it should calculate necessary changes instead.

mauchchhash commented 2 years ago

@chemzqm I don't understand what those codes mean 😅. I hope there is fix...

chemzqm commented 2 years ago

It means all your lines get replaced and neovim not track your marker, should be fixed by vls.

mauchchhash commented 2 years ago

So there's nothing I can do from my end right? Or do I need to create an issue somewhere else like "vuejs/vetur"?

chemzqm commented 2 years ago

Don't know, but I prefer that vls to fix this issue.