Skip to content

Commit

Permalink
Normalize preprocessed output
Browse files Browse the repository at this point in the history
Solves autocomplete over grcp
Fixes arduino/Arduino#6816
  • Loading branch information
facchinm committed Oct 16, 2017
1 parent 6d29a54 commit 3cc1f0f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/arduino.cc/builder/preprocess_sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
package builder

import (
"errors"
"fmt"
"os/exec"
"path/filepath"
"runtime"
"strings"
Expand Down Expand Up @@ -118,14 +120,16 @@ func (s *ArduinoPreprocessorRunner) Run(ctx *types.Context) error {

buf, err := command.Output()
if err != nil {
return i18n.WrapError(err)
return errors.New(i18n.WrapError(err).Error() + string(err.(*exec.ExitError).Stderr))
}
output := string(buf)

result := utils.NormalizeUTF8(buf)

//fmt.Printf("PREPROCESSOR OUTPUT:\n%s\n", output)
if ctx.CodeCompleteAt != "" {
ctx.CodeCompletions = output
ctx.CodeCompletions = string(result)
} else {
ctx.Source = output
ctx.Source = string(result)
}
return nil
}
Expand Down

0 comments on commit 3cc1f0f

Please sign in to comment.