From 7c011282e7494ab8f075ddf88258c18a08bcdf7e Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Thu, 22 Jul 2021 23:05:08 +0900 Subject: [PATCH] Use strings.Replace Debian buster still use Go1.11 --- langserver/handle_text_document_completion.go | 2 +- langserver/handle_text_document_formatting.go | 2 +- langserver/handle_text_document_hover.go | 2 +- langserver/handler.go | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/langserver/handle_text_document_completion.go b/langserver/handle_text_document_completion.go index f189e9f..1642704 100644 --- a/langserver/handle_text_document_completion.go +++ b/langserver/handle_text_document_completion.go @@ -75,7 +75,7 @@ func (h *langHandler) completion(uri DocumentURI, params *CompletionParams) ([]C command := config.CompletionCommand if strings.Contains(command, "${POSITION}") { - command = strings.ReplaceAll(command, "${POSITION}", fmt.Sprintf("%d:%d", params.TextDocumentPositionParams.Position.Line, params.Position.Character)) + command = strings.Replace(command, "${POSITION}", fmt.Sprintf("%d:%d", params.TextDocumentPositionParams.Position.Line, params.Position.Character), -1) } if !config.CompletionStdin && !strings.Contains(command, "${INPUT}") { command = command + " ${INPUT}" diff --git a/langserver/handle_text_document_formatting.go b/langserver/handle_text_document_formatting.go index 58833f4..eef7812 100644 --- a/langserver/handle_text_document_formatting.go +++ b/langserver/handle_text_document_formatting.go @@ -140,7 +140,7 @@ Configs: if h.loglevel >= 1 { h.logger.Println(command+":", string(b)) } - text = strings.ReplaceAll(string(b), "\r", "") + text = strings.Replace(string(b), "\r", "", -1) } if formated { diff --git a/langserver/handle_text_document_hover.go b/langserver/handle_text_document_hover.go index 38aee10..9393107 100644 --- a/langserver/handle_text_document_hover.go +++ b/langserver/handle_text_document_hover.go @@ -107,7 +107,7 @@ func (h *langHandler) hover(uri DocumentURI, params *HoverParams) (*Hover, error if !config.HoverStdin && !strings.Contains(command, "${INPUT}") { command = command + " ${INPUT}" } - command = strings.ReplaceAll(command, "${INPUT}", word) + command = strings.Replace(command, "${INPUT}", word, -1) var cmd *exec.Cmd if runtime.GOOS == "windows" { diff --git a/langserver/handler.go b/langserver/handler.go index cc6d130..cdf690c 100644 --- a/langserver/handler.go +++ b/langserver/handler.go @@ -609,10 +609,10 @@ func replaceCommandInputFilename(command, fname, rootPath string) string { ext := filepath.Ext(fname) ext = strings.TrimPrefix(ext, ".") - command = strings.ReplaceAll(command, "${INPUT}", fname) - command = strings.ReplaceAll(command, "${FILEEXT}", ext) - command = strings.ReplaceAll(command, "${FILENAME}", filepath.FromSlash(fname)) - command = strings.ReplaceAll(command, "${ROOT}", rootPath) + command = strings.Replace(command, "${INPUT}", fname, -1) + command = strings.Replace(command, "${FILEEXT}", ext, -1) + command = strings.Replace(command, "${FILENAME}", filepath.FromSlash(fname), -1) + command = strings.Replace(command, "${ROOT}", rootPath, -1) return command }