简体   繁体   English

如何在 Visual Studio Code 中完全禁用输出滚动锁定?

[英]How to completely disable output scroll lock in Visual Studio Code?

As far as I could gather, even though VS Code's Output Panel has a Toggle Output Scroll Lock icon in its title area据我所知,即使 VS Code 的输出面板在其标题区域中有一个Toggle Output Scroll Lock图标

切换输出滚动锁定

it still uses a feature called smart lock which means scrolling is enabled only if the output area is already scrolled all the way down to the bottom before the new output is generated (more on this here ).它仍然使用称为智能锁的功能,这意味着只有在生成新输出之前输出区域已经一直向下滚动到底部时才启用滚动(更多关于这里)。

I use Code Runner and ensuring output area is manually scrolled down each time I run my code to see anything is driving me nuts.我使用Code Runner并确保每次运行我的代码时手动向下滚动输出区域以查看任何让我发疯的东西。

No solution right now (May 2019)目前没有解决方案(2019 年 5 月)

I don't know if this behavior is intended or if it's a bug, but I think currently there is no real solution to entirely solve this problem.我不知道这种行为是故意的还是一个错误,但我认为目前没有真正的解决方案来完全解决这个问题。

Maybe the provided workarounds help you to better stay in control of how the output scrolling works.也许提供的解决方法可以帮助您更好地控制输出滚动的工作方式。

Workarounds解决方法

Bring focus back to current output将焦点带回到当前输出

  1. Disable scroll lock:禁用滚动锁定: 打开锁定按钮 (lock should now be open) (锁现在应该是打开的)
  2. Click the "Clear Output"-button:单击“清除输出”按钮: 清除输出按钮
    (or open the context menu of the output console (right click) and choose "Clear Output") (或打开输出控制台的上下文菜单(右键单击)并选择“清除输出”)
  3. Remove focus: Make sure the output console is not focused anymore移除焦点:确保输出控制台不再聚焦
  4. Re-run the program重新运行程序
    (with Code Runner : ctrl + alt + N ) (使用Code Runnerctrl + alt + N

Avoid the problem避免问题

If you need to check some output which isn't in the current view, hover over the output window and make sure to just scroll using your mouse wheel without clicking inside the output window .如果您需要检查一些不在当前视图中的输出,请将鼠标悬停在输出窗口上,并确保仅使用鼠标滚轮滚动而不在输出窗口内单击


Tested with VSCode version 1.33.1 and CodeRunner version v0.9.9 .测试了VSCode版本1.33.1CodeRunner版本v0.9.9

It looks like the fix for this was released in March 2020 rather silently, as the hidden setting output.smartScroll.enabled .看起来这个修复程序是在 2020 年 3 月悄悄发布的,因为隐藏设置output.smartScroll.enabled

You'll need to make the following change in settings.json :您需要在settings.json进行以下更改:

  "output.smartScroll.enabled": false

Found this change mentioned here: https://github.com/microsoft/vscode/issues/69480#issuecomment-593401640发现这里提到的这个变化: https : //github.com/microsoft/vscode/issues/69480#issuecomment-593401640

Also, just found this setting - while not the exact fix, it could be a relief to many people.此外,刚刚找到此设置 - 虽然不是确切的解决方法,但对许多人来说可能是一种解脱。 Put the following setting in your settings.json file:将以下设置放入 settings.json 文件中:

    "code-runner.clearPreviousOutput": true,

This will clear the old output every time you run the code and display only the current output.这将在您每次运行代码时清除旧输出并仅显示当前输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM