Skip to content

Commit

Permalink
Merge pull request #154 from mattn/replace-all
Browse files Browse the repository at this point in the history
Use strings.Replace
  • Loading branch information
mattn authored Jul 22, 2021
2 parents dc4e37b + 7c01128 commit bbab558
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion langserver/handle_text_document_completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_formatting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion langserver/handle_text_document_hover.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
8 changes: 4 additions & 4 deletions langserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit bbab558

Please sign in to comment.