Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong text output at DEBUG CONSOLE #2131

Open
kzhui125 opened this issue Mar 23, 2022 · 14 comments
Open

wrong text output at DEBUG CONSOLE #2131

kzhui125 opened this issue Mar 23, 2022 · 14 comments
Labels
Debug Issues related to the debugging functionality of the extension.

Comments

@kzhui125
Copy link

kzhui125 commented Mar 23, 2022

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.17.6 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.8.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.65.2
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.32.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    go: /usr/local/bin/go: go version go1.17.6 darwin/amd64
    go-outline: /Users/zm/go/bin/go-outline (version: v0.0.0-20210608161538-9736a4bde949 built with go: go1.17.6)
    gotests: /Users/zm/go/bin/gotests (version: v1.6.0 built with go: go1.17.6)
    gomodifytags: /Users/zm/go/bin/gomodifytags (version: v1.16.0 built with go: go1.17.6)
    impl: /Users/zm/go/bin/impl (version: v1.1.0 built with go: go1.17.6)
    goplay: /Users/zm/go/bin/goplay (version: v1.0.0 built with go: go1.17.6)
    dlv: /Users/zm/go/bin/dlv (version: v1.8.1 built with go: go1.17.6)
    staticcheck: /Users/zm/go/bin/staticcheck (version: v0.2.2 built with go: go1.17.6)
    gopls: /Users/zm/go/bin/gopls (version: v0.8.1 built with go: go1.17.6)

Share the Go related settings you have added/edited

"go.delveConfig": {
    "apiVersion": 2,
    "showGlobalVariables": true
  },
  "go.formatTool": "goimports",
  "go.useLanguageServer": true,
  "go.testFlags": [
    "-v"
  ],
  "go.languageServerFlags": [
    "-rpc.trace",
  ],
  "[go]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
    },
  },
  "[go.mod]": {
    "editor.formatOnSave": true,
    "editor.codeActionsOnSave": {
      "source.organizeImports": true,
    },
  },
  "gopls": {
    "usePlaceholders": true,
    "completeUnimported": true
  },
"go.toolsManagement.autoUpdate": true,

Describe the bug

bug: the output in DEBUG CONSOLE is not the same as the content of test.txt

expected: the output should be the content of test.txt

Steps to reproduce the behavior:

  1. go mod init gtest
  2. write main.go
package main

import (
	"fmt"
	"io/ioutil"
)

func main() {
	data, err := ioutil.ReadFile(`/path/to/test.txt`)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(data))
	fmt.Println("end")
}
  1. set breakpoint at line fmt.Println("end")
  2. debug main.go
  3. debug console: output is not expected as the same as test.txt

Screenshots or recordings

the test.txt is attacted:

test.txt

go

@gopherbot gopherbot added this to the Untriaged milestone Mar 23, 2022
@findleyr
Copy link
Member

Hi, is the only difference those invalid characters indicated with the arrow?

This is most likely an encoding issue in the debug console, and therefore not really related to VS Code Go. However, if you can try the following we can perhaps narrow it down:

  1. reproduce using a shorter text file, containing just those characters
  2. check if those characters print when running from the vscode integrated terminal
  3. check if those characters are formatted correctly from within Go source code in the vs code editor

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 23, 2022
@kzhui125
Copy link
Author

@findleyr test.txt is attached, can you reproduce?

@kzhui125
Copy link
Author

With shorter text file, I don’t reproduce.

In the example: the only difference are those invalid characters indicated with the arrow.

@findleyr
Copy link
Member

@kzhui125 this issue tracker is maintained by a small number of engineers working on primarily on Go, and this problem does not yet appear directly related to Go or the Go extension. We don't have unlimited resources to investigate every problem and so try to first isolated whether the problem is related to the extension.

Thanks for trying with a shorter text file. Can you produce a minimal text file that reproduces the problem?

What about the other steps: are the characters formatted correctly in the integrated terminal, or if you open the file as a VS Code tab?

@kzhui125
Copy link
Author

I don't know how does this bug happen, so I can't produce a shorter text.

the text.txt I attaced is the minimal text file I can produce now:

1

are the characters formatted correctly in the integrated terminal:
formatted correctly

or if you open the file as a VS Code tab:
formatted correctly

@kzhui125
Copy link
Author

I have tried using VSCode to debug js code, using the same text.txt file, and it works fine.

So this might not be a issue of VSCode side.

By the way, I think the ![图1-1](https://test.com/file/abcdefg.jpg) line in the text file may be the cause of the issue.

1

@findleyr findleyr removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 23, 2022
@findleyr
Copy link
Member

Hi, could you try setting "console": "integratedTerminal" in your launch config?

More details here:
https://github.com/golang/vscode-go/blob/master/docs/debugging.md#configuration

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 25, 2022
@kzhui125
Copy link
Author

@findleyr
"console": "integratedTerminal" works fine

this problem is only related to debug console

@kzhui125
Copy link
Author

I have provided you the code and test.txt file. You can reproduce by yourself too.

@kzhui125
Copy link
Author

I don’t know this bug is related to vscode or vscode-go extension, can you confirm?

@findleyr
Copy link
Member

@kzhui125 we discussed in our triage today. This is a problem in the vscode-go extension, where it truncates based on byte offsets rather than character offsets (and therefore corrupts some characters).

I think since there is a viable workaround, and this only impacts large output, we are unlikely to prioritize this anytime soon.

@findleyr findleyr modified the milestones: Untriaged, Unplanned Mar 25, 2022
@findleyr findleyr removed the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Mar 25, 2022
@kzhui125
Copy link
Author

Thanks, but I often debug testing file functions instead of main.go, how can I use integrated terminal in this way

@hyangah hyangah added the Debug Issues related to the debugging functionality of the extension. label Mar 25, 2022
@hyangah
Copy link
Contributor

hyangah commented Mar 25, 2022

Create a test configuration and start debug test with F5.
There is an open issue about allowing users to provide custom launch configuration for code lenses and test explorer.
(#855) But I am not sure when/who/how it will be addressed.

@DomPedrinacio
Copy link

Bro, i have a litle problem with my code, iam a JavaScript and React developer, and i dont wanna write a simple code of "if and else if" because my debug console have a show a litle bit problema when he says:
"ERROR: Invalid character \u201c' at undefined
Console output:"
Wtf is going on??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debug Issues related to the debugging functionality of the extension.
Projects
None yet
Development

No branches or pull requests

5 participants