rust-analyzer icon indicating copy to clipboard operation
rust-analyzer copied to clipboard

There are inconsistencies when clicking 'run' and 'debug' on the main function.

Open aphage opened this issue 1 year ago • 7 comments

rust-analyzer version: rust-analyzer version: 0.3.2053-standalone (fd74511f3 2024-07-28)

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

editor or extension: Version: 1.91.1 (system setup)

  • Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
  • Date: 2024-07-09T22:06:49.809Z
  • Electron: 29.4.0
  • ElectronBuildId: 9728852
  • Chromium: 122.0.6261.156
  • Node.js: 20.9.0
  • V8: 12.2.281.27-electron.0
  • OS: Windows_NT x64 10.0.22631

relevant settings: default

code snippet to reproduce:

fn main() {
    println!("Hello, world!");
    println!("你好,世界!");
}

屏幕截图 2024-08-01 084611 屏幕截图 2024-08-01 085101

There are inconsistencies when clicking 'run' and 'debug' on the main function.

aphage avatar Aug 01 '24 01:08 aphage

CodeLLDB: v1.10.0

aphage avatar Aug 01 '24 01:08 aphage

~What inconsistencies specifically?~ Ah the output is scrambled in the latter

Veykril avatar Aug 01 '24 08:08 Veykril

~What inconsistencies specifically?~ Ah the output is scrambled in the latter

yes.

aphage avatar Aug 02 '24 00:08 aphage

This might be an issue about encoding of the terminal: UTF-8 is used during runtime, but a different encoding (possibly GBK) is used during debugging.

Due to historical reasons, Windows has not fully migrated to UTF-8, leading to this problem (which cannot be reproduced on Linux or macOS).

roife avatar Aug 02 '24 06:08 roife

Can we somehow work around this? (by being explicit about encodings within the extension somewhere maybe?)

Veykril avatar Aug 02 '24 06:08 Veykril

Emmm, this issue might occur wherever CodeLLDB (or the cmd) is used, so I believe the best approach is to change settings in terminal.integrated.profiles.windows.

"terminal.integrated.profiles.windows": {
	"PowerShell": {
		"source": "PowerShell",
		"icon": "terminal-powershell",
		"args": ["-NoExit", "chcp 65001"]
	},
	"Command Prompt": {
		"path": [
			"${env:windir}\\Sysnative\\cmd.exe",
			"${env:windir}\\System32\\cmd.exe"
		],
		"args": ["/K", "chcp 65001"],
		"icon": "terminal-cmd"
	},
	"Git Bash": {
		"source": "Git Bash"
	}
}

Here chcp 65001 is used to enable UTF-8.

roife avatar Aug 02 '24 07:08 roife

OK, should we close this issue?

aphage avatar Aug 02 '24 08:08 aphage