-
Notifications
You must be signed in to change notification settings - Fork 384
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
feat(editor): add a preference prevent scroll after get focused #3846
Conversation
🚅 Previously deployed to Railway in the core project. Environment has been deleted. |
/next |
Walkthrough这些更改引入了多个模块的若干改进,包括新增了鼠标事件按钮常量、在不同位置增加了防止滚动选项、改变了一些事件处理逻辑以及引入了新的配置属性。这些变更整体上提升了代码的可维护性和功能性。 Changes
Sequence Diagram(s)默默忽略该部分,因为变更过于简单或多样化,不适合生成序列图。 Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- packages/core-browser/src/dom/index.ts (1 hunks)
- packages/core-browser/src/services/clipboard.service.ts (1 hunks)
- packages/core-common/src/settings/general.ts (1 hunks)
- packages/editor/src/browser/monaco-contrib/command/command.service.ts (1 hunks)
- packages/editor/src/browser/tab.view.tsx (3 hunks)
- packages/editor/src/browser/workbench-editor.service.ts (6 hunks)
- packages/editor/src/common/editor.ts (1 hunks)
- packages/terminal-next/src/browser/component/tab.item.tsx (1 hunks)
- packages/theme/src/browser/icon.service.ts (1 hunks)
Files skipped from review due to trivial changes (4)
- packages/editor/src/browser/monaco-contrib/command/command.service.ts
- packages/editor/src/browser/tab.view.tsx
- packages/editor/src/common/editor.ts
- packages/terminal-next/src/browser/component/tab.item.tsx
Additional comments not posted (10)
packages/core-common/src/settings/general.ts (1)
Line range hint
1-6
:
更改const enum
为标准enum
此更改将
const enum
转换为标准enum
。这可能是为了提高兼容性或提供更多的灵活性。packages/core-browser/src/services/clipboard.service.ts (2)
38-40
: 添加preventScroll
选项到focus
调用在
textArea.focus
调用中添加preventScroll: true
选项,以防止聚焦时自动滚动到视图中。这符合 PR 的目标,防止自动滚动行为。
46-48
: 添加preventScroll
选项到focus
调用在
activeElement.focus
调用中添加preventScroll: true
选项,以防止聚焦时自动滚动到视图中。这符合 PR 的目标,防止自动滚动行为。packages/core-browser/src/dom/index.ts (1)
178-188
: 添加MouseEventButton
常量新常量
MouseEventButton
提供了鼠标按键类型的清晰枚举,提高了代码的可读性和可维护性。packages/theme/src/browser/icon.service.ts (1)
98-104
: 使用onSpecificPreferenceChange
处理偏好设置更改使用
onSpecificPreferenceChange
而不是onPreferenceChanged
提高了偏好设置更改处理的特异性和效率。packages/editor/src/browser/workbench-editor.service.ts (5)
1347-1350
: 新增方法:获取 preventScroll 选项这个方法从提供的选项或偏好服务中检索
preventScroll
选项。代码看起来正确且逻辑清晰。
1374-1377
: 添加 preventScroll 选项到焦点方法在
doOpen
方法中,代码现在在聚焦 DOM 节点之前检查并设置preventScroll
选项。代码看起来正确且逻辑清晰。
1623-1624
: 添加 preventScroll 选项到焦点方法在
openCodeEditor
方法中,代码现在在聚焦 DOM 节点之前检查并设置preventScroll
选项。代码看起来正确且逻辑清晰。
1676-1679
: 添加 preventScroll 选项到焦点方法在
openDiffEditor
方法中,代码现在在聚焦 DOM 节点之前检查并设置preventScroll
选项。代码看起来正确且逻辑清晰。
2208-2208
: 添加 preventScroll 选项到焦点方法在
focus
方法中,代码现在使用getPreventScrollOption
方法来处理preventScroll
逻辑。代码看起来正确且逻辑清晰。
🎉 PR Next publish successful! 3.1.5-next-1720766832.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (9)
- packages/core-browser/src/dom/index.ts (1 hunks)
- packages/core-browser/src/services/clipboard.service.ts (1 hunks)
- packages/core-common/src/settings/general.ts (1 hunks)
- packages/editor/src/browser/monaco-contrib/command/command.service.ts (1 hunks)
- packages/editor/src/browser/tab.view.tsx (3 hunks)
- packages/editor/src/browser/workbench-editor.service.ts (6 hunks)
- packages/editor/src/common/editor.ts (1 hunks)
- packages/terminal-next/src/browser/component/tab.item.tsx (1 hunks)
- packages/theme/src/browser/icon.service.ts (1 hunks)
Files skipped from review due to trivial changes (5)
- packages/core-browser/src/dom/index.ts
- packages/core-common/src/settings/general.ts
- packages/editor/src/browser/monaco-contrib/command/command.service.ts
- packages/editor/src/common/editor.ts
- packages/terminal-next/src/browser/component/tab.item.tsx
Additional comments not posted (11)
packages/core-browser/src/services/clipboard.service.ts (2)
38-40
: 确保 focus 方法中的 preventScroll 选项正确使用在调用
textArea.focus
方法时,添加了preventScroll: true
选项,以防止页面滚动。此更改是合适的,但请确保在所有相关场景中都需要此行为。
46-48
: 确保 focus 方法中的 preventScroll 选项正确使用在调用
activeElement.focus
方法时,添加了preventScroll: true
选项,以防止页面滚动。此更改是合适的,但请确保在所有相关场景中都需要此行为。packages/theme/src/browser/icon.service.ts (1)
98-104
: 更新监听方法以使用 onSpecificPreferenceChange此更改将
listen
方法从onPreferenceChanged
更新为onSpecificPreferenceChange
,并在应用主题之前检查iconContributionRegistry
。这增强了事件处理逻辑。packages/editor/src/browser/tab.view.tsx (4)
25-25
: 引入 MouseEventButton 常量引入
MouseEventButton
常量以标准化鼠标按钮值。这是一个良好的实践,有助于提高代码的可读性和维护性。
176-179
: 防止标签获取焦点时滚动在调用
scrollIntoView
方法时,添加了block: 'nearest'
和inline: 'nearest'
选项,以防止标签获取焦点时滚动。请确保此更改符合预期行为。
432-432
: 使用 MouseEventButton.Middle 常量更新
onMouseUp
事件处理程序以使用MouseEventButton.Middle
常量,而不是检查e.nativeEvent.which === 2
。此更改提高了代码的一致性和可读性。
439-439
: 使用 MouseEventButton.Left 常量更新
onMouseDown
事件处理程序以使用MouseEventButton.Left
常量,而不是检查e.nativeEvent.which === 1
。此更改提高了代码的一致性和可读性。packages/editor/src/browser/workbench-editor.service.ts (4)
1347-1350
: 代码通过,但请验证偏好设置的使用情况这个新函数
getPreventScrollOption
实现了从IResourceOpenOptions
或偏好设置中获取preventScroll
选项的功能。建议检查偏好设置是否在代码库的其他部分正确设置和使用。
1623-1624
: 代码通过,但请验证 preventScroll 的使用在
openCodeEditor
函数中添加了对getPreventScrollOption
的调用,并在focus
调用中使用了preventScroll
选项。建议确保在focus
调用中正确使用preventScroll
。Verification successful
代码通过,但请验证 preventScroll 的使用
在
openCodeEditor
函数中添加了对getPreventScrollOption
的调用,并在focus
调用中使用了preventScroll
选项。建议确保在focus
调用中正确使用preventScroll
。
zone-widget.ts
:activeElement?.focus({ preventScroll: true });
workbench-editor.service.ts
:this._domNode?.focus({ preventScroll });
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. Expect: Occurrences of `preventScroll` usage in focus calls. rg --type js --type ts --pattern 'focus\(\s*\{[^}]*preventScroll'Length of output: 479
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. Expect: Occurrences of `preventScroll` usage in focus calls. rg 'focus\(\s*\{[^}]*preventScroll' --type js --type tsLength of output: 264
1374-1377
: 代码通过,但请验证 preventScroll 的使用在
doOpen
函数中添加了对getPreventScrollOption
的调用,并使用了preventScroll
选项。建议确保在focus
调用中正确使用preventScroll
。Verification successful
代码通过,但请验证 preventScroll 的使用
在
doOpen
函数中添加了对getPreventScrollOption
的调用,并使用了preventScroll
选项。经验证,focus
调用中的preventScroll
选项在代码库中正确使用。
packages/monaco-enhance/src/browser/zone-widget.ts
packages/editor/src/browser/workbench-editor.service.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. Expect: Occurrences of `preventScroll` usage in focus calls. rg --type js --type ts --pattern 'focus\(\s*\{[^}]*preventScroll'Length of output: 479
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. Expect: Occurrences of `preventScroll` usage in focus calls. rg 'focus\(\s*\{[^}]*preventScroll' --type js --type tsLength of output: 264
1676-1679
: 代码通过,但请验证 preventScroll 的使用在
openDiffEditor
函数中添加了对getPreventScrollOption
的调用,并在focus
调用中使用了preventScroll
选项。建议确保在focus
调用中正确使用preventScroll
。Verification successful
代码通过,但请验证 preventScroll 的使用
在
openDiffEditor
函数中添加了对getPreventScrollOption
的调用,并在focus
调用中使用了preventScroll
选项。建议确保在focus
调用中正确使用preventScroll
。
packages/monaco-enhance/src/browser/zone-widget.ts
文件中有类似的preventScroll
使用方式。packages/editor/src/browser/workbench-editor.service.ts
文件中正确使用了preventScroll
。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. Expect: Occurrences of `preventScroll` usage in focus calls. rg --type js --type ts --pattern 'focus\(\s*\{[^}]*preventScroll'Length of output: 479
Script:
#!/bin/bash # Description: Verify `preventScroll` usage in focus calls. # Test: Search for `focus` calls with `preventScroll` option. rg --type js --type ts 'focus\(\s*\{[^}]*preventScroll'Length of output: 264
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3846 +/- ##
=======================================
Coverage 54.99% 55.00%
=======================================
Files 1556 1557 +1
Lines 94800 94813 +13
Branches 19406 19409 +3
=======================================
+ Hits 52132 52148 +16
+ Misses 35451 35450 -1
+ Partials 7217 7215 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (1)
packages/editor/src/browser/preference/schema.ts (1)
1501-1505
: 缺少本地化键%editor.configuration.preventScrollAfterFocused%
。请确保在适当的本地化文件中添加此键,以便正确翻译描述。
- 更新
packages/editor/src/browser/preference/schema.ts
文件中添加的描述键。Analysis chain
新添加的偏好设置
editor.preventScrollAfterFocused
看起来不错!请确保描述
%editor.configuration.preventScrollAfterFocused%
已正确本地化。Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the localization key for `editor.preventScrollAfterFocused` is defined. # Test: Search for the localization key. Expect: The key should be defined. rg '%editor.configuration.preventScrollAfterFocused%'Length of output: 171
Script:
#!/bin/bash # Description: Verify the localization key for `editor.preventScrollAfterFocused` is defined in localization files. # Test: Search for the localization key in all localization files. Expect: The key should be defined. rg '%editor.configuration.preventScrollAfterFocused%' --glob '*local*'Length of output: 70
Script:
#!/bin/bash # Description: Perform a targeted search for the localization key in specific localization files. # Test: Search for the localization key in known localization directories. Expect: The key should be defined. rg '%editor.configuration.preventScrollAfterFocused%' --glob 'packages/**/locales/*'Length of output: 233
Script:
#!/bin/bash # Description: Perform a broader search for the localization key and debug why files might be skipped. # Test: Search for the localization key in all files and use debug mode to understand any issues. rg '%editor.configuration.preventScrollAfterFocused%' --debugLength of output: 12413
/next |
1 similar comment
/next |
🎉 PR Next publish successful! 3.1.5-next-1720770997.0 |
这个配置在以下场景中非常有用:
|
Types
Background or solution
点击 tab 的时候,会调用
group.open(uri, {focus: true})
,该方法内部调用了 Element.prototype.focus, 这个方法会使得元素被滚动到视图Changelog
add a preference that can prevent scroll after editor get focus
Summary by CodeRabbit
新功能
MouseEventButton
常量,用于表示不同的鼠标按键。IResourceOpenOptions
接口中新增了preventScroll
属性。customEditorSchema
中新增了editor.preventScrollAfterFocused
属性。改进
BrowserClipboardService
类中的focus()
方法现在包含preventScroll: true
参数。MonacoCommandRegistry
类中的execute
方法现在直接返回monacoHandler.execute
的结果。IconService
类中的listen
方法改用onSpecificPreferenceChange
进行事件处理。修复
tab.view.tsx
中的滚动行为处理,以及鼠标事件处理的逻辑。