Skip to content

Commit 4fe5428

Browse files
facchinmcmaglie
authored andcommitted
Normalize preprocessed output
Solves autocomplete over grcp Fixes arduino/Arduino#6816
1 parent 44aeba7 commit 4fe5428

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Diff for: preprocess_sketch.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
package builder
3131

3232
import (
33+
"errors"
3334
"fmt"
35+
"os/exec"
3436
"path/filepath"
3537
"runtime"
3638
"strings"
@@ -118,14 +120,16 @@ func (s *ArduinoPreprocessorRunner) Run(ctx *types.Context) error {
118120

119121
buf, err := command.Output()
120122
if err != nil {
121-
return i18n.WrapError(err)
123+
return errors.New(i18n.WrapError(err).Error() + string(err.(*exec.ExitError).Stderr))
122124
}
123-
output := string(buf)
125+
126+
result := utils.NormalizeUTF8(buf)
127+
124128
//fmt.Printf("PREPROCESSOR OUTPUT:\n%s\n", output)
125129
if ctx.CodeCompleteAt != "" {
126-
ctx.CodeCompletions = output
130+
ctx.CodeCompletions = string(result)
127131
} else {
128-
ctx.Source = output
132+
ctx.Source = string(result)
129133
}
130134
return nil
131135
}

0 commit comments

Comments
 (0)