Skip to content
This repository has been archived by the owner on Jun 15, 2023. It is now read-only.

Fix multiple string replacement when using TextEdit #158

Open
wants to merge 1 commit into
base: 1.7.0
Choose a base branch
from

Conversation

danielkrusegit
Copy link

@danielkrusegit danielkrusegit commented Jan 20, 2021

This pull-request is related the following issue: #152

Issue
The implementation of a completion is working fine when using the CompletionContributor to modify the document but when an InsertHandler is added to the LookupElement using a TextEdit, the affected text is replaced twice.

The CompletionContributor replaces the text in the range to an empty LookUpString. Afterwards, the InsertHandler is called, which replaces the affected Range again, which is no longer present.

Example
issue

The completion starts with
hello : Intege; //Test
The CompletionContributor replaces Intege to blank
hello : ; //Test
The InsertHandler replaces the range of the Intege that is now ; //Te to Integer64
hello : Integer64st

Server response:

[
  left = null
  right = CompletionList [
  isIncomplete = false
    items = ArrayList (
      CompletionItem [
        label = "Integer64"
        textEdit = TextEdit [
          range = Range [
            start = Position [
              line = 1
              character = 10
            ]
            end = Position [
              line = 1
              character = 16
            ]
          ]
          newText = "Integer64"
        ]
        kind = Interface
        sortText = "2)Integer64"
        commitCharacters = ArrayList (
          "."
        )
        data = {}
        detail = null
        documentation = null
        deprecated = null
        preselect = null
        filterText = null
        insertText = null
        insertTextFormat = null
        additionalTextEdits = null
        command = null
      ]
    )
  ]
] 

Solution
I solved the issue by skipping the first step. The CompletionContributor replaces now from Intege to Intege (No changes in the document). Maybe there is a better solution to solve this issue.

@danielkrusegit danielkrusegit changed the title IMPORTANT: Fix multiple string replacement when using TextEdit Fix multiple string replacement when using TextEdit Feb 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant