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

Truncation of intellisense inlay hints doesn't respect editor.inlayHints.maximumLength option #13130

Open
bradphelan opened this issue Jan 8, 2025 · 6 comments
Labels
enhancement Improvement to an existing feature Feature: Inlay Hint An issue related to inlay hints for declarations and parameters. Language Service
Milestone

Comments

@bradphelan
Copy link

Environment

System Info
Item Value
CPUs AMD Ryzen 9 5900X 12-Core Processor (24 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 63.93GB (43.07GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (62)
Extension Author (truncated) Version
Bookmarks ale 13.5.0
vite ant 0.2.5
scratchpads bue 1.0.0
doxdocgen csc 1.4.0
vscode-eslint dba 3.0.10
python-environment-manager don 1.2.4
python-extension-pack don 1.7.0
gitlens eam 16.1.1
prettier-vscode esb 11.0.0
codespaces Git 1.17.3
copilot Git 1.254.0
copilot-chat Git 0.23.2
cpp-reference Guy 0.2.5
vscode-test-explorer hbe 2.22.1
debug-visualizer hed 2.4.0
better-cpp-syntax jef 1.27.1
vsc-python-indent Kev 1.18.0
copy-json-path Mal 1.3.0
autoclose mar 0.0.1
file-downloader min 1.0.13
git-web-link mro 1.2.0
vscode-docker ms- 1.29.3
vscode-dotnet-runtime ms- 2.2.3
debugpy ms- 2024.14.0
isort ms- 2023.10.1
python ms- 2024.22.0
vscode-pylance ms- 2024.12.1
remote-containers ms- 0.395.0
remote-ssh ms- 0.116.1
remote-ssh-edit ms- 0.87.0
remote-wsl ms- 0.88.5
vscode-remote-extensionpack ms- 0.26.0
cmake-tools ms- 1.19.52
cpptools ms- 1.23.2
cpptools-extension-pack ms- 1.3.0
hexeditor ms- 1.11.1
makefile-tools ms- 0.11.13
powershell ms- 2024.4.0
remote-explorer ms- 0.4.3
remote-server ms- 1.5.2
test-adapter-converter ms- 0.2.1
vscode-speech ms- 0.12.1
autodocstring njp 0.6.1
parse-tree pok 0.32.0
svelte-extractor pro 0.0.3
make-runner raj 1.0.3
vscode-xml red 0.27.2
command-variable rio 1.66.0
shader sle 1.1.5
memento-inputs spa 1.0.0
code-spell-checker str 4.0.21
svelte-vscode sve 109.4.0
ayu tea 1.0.5
textual-syntax-highlighter Tex 1.3.0
cmake twx 0.0.17
vscode-lldb vad 1.11.1
intellicode-api-usage-examples Vis 0.2.9
vscodeintellicode Vis 1.3.2
vim vsc 1.29.0
debug web 0.27.0
jinja who 0.0.8
markdown-all-in-one yzh 3.6.2

(5 theme extensions excluded)

A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
vsaa593:30376534
py29gd2263:31024238
c4g48928:30535728
2i9eh265:30646982
962ge761:30841072
pythonnoceb:30776497
dsvsc014:30777825
dsvsc015:30821418
pythonmypyd1:30859725
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:30980852
pythonait:30973460
dvdeprecation:31040973
dwnewjupyter:31046869
nativerepl1:31134653
pythonrstrctxt:31093868
nativeloc1:31118317
cf971741:31144450
e80f6927:31120813
iacca1:31150324
notype1:31143044
dwcopilot:31158714
h409b430:31177054
cf1a2727:31183122
c3hdf307:31184662
6074i472:31201624

Bug Summary and Steps to Reproduce

Type: Bug

Using the setting.

"editor.inlayHints.maximumLength":0 

with 0 I get

Image

with 1 I get

Image

with 10 I get

Image

with 20 I get

Image

with 40 I get

Image

with 80 I get

Image

This has been setup with the CPP inlay hints configuration to ensure it targets C++. I think for some reason the bug fix in microsoft/vscode#205708 is not working for C++

Configuration and Logs

[log-diagnostics.txt](https://github.com/user-attachments/files/18349107/log-diagnostics.txt)

Other Extensions

No response

Additional context

This issue was ported from the core vs-code team because they claim it is the cpp plugin issue rather than core.

microsoft/vscode#236861 (comment)

@bradphelan bradphelan changed the title Truncation of inlay hints doesn't respect editor.inlayHints.maximumLength option Truncation of intellisense inlay hints doesn't respect editor.inlayHints.maximumLength option Jan 8, 2025
@bobbrow
Copy link
Member

bobbrow commented Jan 8, 2025

We weren't aware of the new setting. It shouldn't be too big a problem to add support for it.

@bobbrow bobbrow added Language Service Feature: Inlay Hint An issue related to inlay hints for declarations and parameters. enhancement Improvement to an existing feature labels Jan 8, 2025
@bobbrow bobbrow added this to the On Deck milestone Jan 8, 2025
@bobbrow bobbrow moved this to Todo in cpptools Jan 8, 2025
@sean-mcmanus
Copy link
Contributor

sean-mcmanus commented Jan 8, 2025

@bradphelan Internally we have our own maximum length that we apply (the "..." in the middle). VS Code's setting is applied by VS Code on the result we send it (the other dot dot dot (i.e. \u2026) symbol on the right).

The current hardcoded implementation of the "in the middle" truncation is in the accordion_string function (shared with VS).

@bradphelan
Copy link
Author

The same note that I made to the core team. I think truncating in the middle is the wrong place. C++ identifiers are normally from left to right, least specific to most specific. ie:

com::microsoft::geometry::linear::cross_product

If you were going to truncate it makes more sense to truncate at the left

...ear::cross_product

rather than

com::.micro...uct

@sean-mcmanus
Copy link
Contributor

@bradphelan We use accordion style truncation (inherited from VS), because for scenarios with the std libraries there are cases where the stuff on the right side is like iterator and supposedly there are many cases like that with the "ranges" library and is missing distinguishing info. But we could potentially add a setting for that.

Image

@bradphelan
Copy link
Author

This is still pretty random.

std::list<std...onst_iterator

is terrible. Either

::const_iterator

or

std::list<...>::const_iterator

or

std::list<>::const_iterator

but not random truncation in middle of words. In my code base I get stuff like.

Image

which is terribly frustrating. In this case it would be surely better to truncate the namespace prefix rather than the important more specific name at the end.

There also needs to be more coordination with the base editor so that at minimum when you mouse over a truncated inlay hint you get the full type. This should also work together with a refactoring option on any auto declaration to replace it with the specific type the inlay hint is showing.

@bradphelan
Copy link
Author

bradphelan commented Jan 14, 2025

Interestingly copilot has access to the full inferred type even though the inlay hint has been truncated.

Image

I'm not sure if it's just getting lucky hallucinating the correct type or it has pulled it from somewhere. But it would be nice if this was a simple refactoring built in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to an existing feature Feature: Inlay Hint An issue related to inlay hints for declarations and parameters. Language Service
Projects
Status: Todo
Development

No branches or pull requests

3 participants