-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
SimpleFindWidget Add next,previous,history: Fixes #29708 #29661 #32113
SimpleFindWidget Add next,previous,history: Fixes #29708 #29661 #32113
Conversation
product.json
Outdated
"urlProtocol": "code-oss", |
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.
you don't want to check in this, right :)
@rebornix BTW I saw in the August milestones the re- factoring of the FindWidget and a red ball indicating |
@@ -44,4 +47,12 @@ export class TerminalFindWidget extends SimpleFindWidget { | |||
protected onFocusTrackerBlur() { | |||
this._terminalService.getActiveInstance().notifyFindWidgetFocusChanged(false); | |||
} | |||
|
|||
protected onFindInputFocusTrackerFocus() { |
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.
We'd better not expose input box to external callers, let's handle input, checkboxes inside the widget.
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.
@rebornix
I really wanted to hide this further but for right now the context key has to come from above
@@ -54,12 +53,14 @@ import { IContextKeyService, RawContextKey, ContextKeyExpr, IContextKey } from ' | |||
import { Command } from 'vs/editor/common/editorCommonExtensions'; | |||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; | |||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; | |||
import { default as WebView, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_INPUT_FOCUSED } from 'vs/workbench/parts/html/browser/webview'; |
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.
Let's align the casing this time, use Webview
always instead of mix of both WebView
and Webview
.
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.
Done
) { | ||
super(_contextViewService); | ||
|
||
this._findInputFocused = _findInputContextKey.bindTo(this._contextKeyService); | ||
console.debug(this._findInputContextKey.keys()); |
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.
✂️
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.
Doh, have to get find in open files working! Bad stray console lines.
actionRegistry.registerWorkbenchAction(new SyncActionDescriptor(NextMatchTerminalFindWidgetAction, NextMatchTerminalFindWidgetAction.ID, NextMatchTerminalFindWidgetAction.LABEL, { | ||
primary: KeyCode.F3, | ||
mac: { primary: KeyMod.CtrlCmd | KeyCode.KEY_G, secondary: [KeyCode.F3] } | ||
}, KEYBINDING_CONTEXT_TERMINAL_FOCUS), 'Terminal: Find Next', category); |
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.
Terminal:
prefix is redundant.
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.
Done
Issues found while playing with it locally
|
@rebornix Update: The editor FindWidget does use an update history delay: I can make this parallel |
A few more adds and will have two competing find widgets ;-) |
@cleidigh your latest change looks good to me. Currently I only have one question left, is it necessary to create keyshorts for ShowNextFind/ShowPreviousFind for every context (Terminal, Extension Editor, Webview)? The key shortcuts are all the same and the context doesn't affect the behavior. You may want to simply create two generic commands which covers all of them. FindPrevious/FindNext is good, they sit where they should be 👍 @mjbvz it makes a few changes to webview so I'd like to have you review it. |
We can probably have a generic context key called |
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.
Webview changes look good overall. I'd like to see if we can minimize the number of duplicate commands though and just have a single set of commands for navigating any find widget's history
@rebornix Lastly, it seems like we would have to demultiplex somewhere in the middle of the call stack |
@rebornix |
@cleidigh there are several possible approaches
The first approach is more intuitive and straightforward to me. |
@rebornix I don't like the hardwired Keybord event handling within the widget either. I will work on option one, probably take me a bit given my limitations and learning to do it correctly. |
@cleidigh no worries, ping me whenever you need suggestions or so. Thanks for doing most of the code work for me, it used to be my debt task :) |
@rebornix I thought I had the right place to add the simple find widget command contributions: Thanks |
@cleidigh did you add this file to https://github.com/Microsoft/vscode/blob/master/src/vs/editor/editor.all.ts#L44 ? |
@rebornix |
@cleidigh for editor contributions, we usually have a controller, in which we registers commands, and the controller usually gets added to BTW, I really appreciate your help on this but I don't want it to take too much of your time. So we can make the PR focus on you intended to do and have it merge fast. Then everyone interested in this topic can jump in and help fix things. If you need any kind of help, let me know, you can even add me to your fork and let me contribute there (fix annoying hidden magic things like this one). Have a good weekend. |
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.
works save placeholder - cleanup to follow Monday afternoon
Commenting on your remarks Friday: That said, I of course don't want to be in the way of progress. I think this PR is ready for a good review cc: @Tyriar I made a fair amount of changes, actually mostly removing code, to the integrated terminal and webView |
@@ -122,6 +124,11 @@ export abstract class TerminalService implements ITerminalService { | |||
} | |||
} | |||
|
|||
// ContextKey to match terminal with simpleFindWidget | |||
public getTerminalFocusContextKey(): IContextKey<boolean> { |
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.
Remove since we already have the terminalFocusContextKey
getter at line 41?
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.
Done
super(_contextViewService); | ||
super(_contextViewService, _contextKeyService, _simpleFindWidgetService); | ||
|
||
// this._findInputFocused = _findInputContextKey.bindTo(this._contextKeyService); |
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.
Remove?
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.
Done
@IContextKeyService _contextKeyService: IContextKeyService, | ||
@ISimpleFindWidgetService _simpleFindWidgetService: ISimpleFindWidgetService, | ||
private webview: Webview, | ||
// private _findInputContextKey: RawContextKey<boolean> |
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.
Remove?
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.
Done
@@ -33,7 +27,7 @@ export const KEYBINDING_CONTEXT_WEBVIEWEDITOR_NOT_FOCUSED: ContextKeyExpr = KEYB | |||
export abstract class WebviewEditor extends BaseWebviewEditor { | |||
|
|||
protected _webviewFocusContextKey: IContextKey<boolean>; | |||
protected _webview: WebView; | |||
protected _webview: Webview; |
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.
Change this and the import back to it's regular casing?
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.
Done
@@ -442,12 +449,30 @@ export default class Webview { | |||
this._findStarted = false; | |||
this._webview.stopFindInPage(keepSelection ? StopFindInPageActions.keepSelection : StopFindInPageActions.clearSelection); | |||
} | |||
/* |
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.
Remove comments?
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.
How did I miss that???
No more late-night commits ;-)
import { Command } from 'vs/editor/common/editorCommonExtensions'; | ||
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService'; | ||
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry'; | ||
import { default as Webview } from 'vs/workbench/parts/html/browser/webview'; |
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.
Change the casing back to normal
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.
Done
|
||
/** A context key that is set when an extension editor webview has focus. */ | ||
export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS = new RawContextKey<boolean>('extensionEditorWebviewFocus', undefined); | ||
/** A context key that is set when an extension editor webview not have focus. */ | ||
export const KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_NOT_FOCUSED: ContextKeyExpr = KEYBINDING_CONTEXT_EXTENSIONEDITOR_WEBVIEW_FOCUS.toNegated(); | ||
|
||
|
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.
Remove extra space
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.
Done
@@ -632,6 +633,9 @@ export class Workbench implements IPartService { | |||
this.toShutdown.push(this.quickOpen); | |||
serviceCollection.set(IQuickOpenService, this.quickOpen); | |||
|
|||
// cleidigh |
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.
Remove comment
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.
Done
|
||
constructor( | ||
@IContextViewService private _contextViewService: IContextViewService, | ||
@IContextKeyService private _contextKeyService: IContextKeyService, | ||
@ISimpleFindWidgetService private _simpleFindWidgetService: ISimpleFindWidgetService, | ||
private animate: boolean = true |
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.
_animate
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.
@Tyriar
I found many pre-existing inconsistencies for private variables , eg some with underscore some without.
When working with any files should I fix these types of things? Change any private variables
to use underscore?
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.
I know there are inconsistencies, try to stick to the style of the file, all the properties and constructor args above use the _ prefix
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.
Okay, will follow that convention
Done
} | ||
|
||
// Allow subclass to provide find | ||
public baseFind(previous: boolean) { |
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.
What is this.find? Can subclasses just reimplement that instead?
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.
Mistaken thought that base class function was required.
Removed, tested.
@Tyriar I can change to whatever you guys want. |
@Tyriar Does this effect commands like |
@mjbvz If it is desired show/focus either the Find or simpleFind from anywhere including the command palette |
@rebornix Existing Find/simpleFind commands and behavior: Show/Focus Find:
Terminal simpleFind: Show/Focus:
ExtensionEditor and WebView (readme,MarkDown): Show/Focus:
Intermediary commit abaae0cc6ea88060d3d8912ef7befdfafc829795 :
Latest PR Commit:
These commands do not show up in the command pallet. Questions:
|
d820ee1
to
25c79be
Compare
25c79be
to
bda04b8
Compare
@cleidigh thanks for your great work. Sat with @mjbvz this afternoon and went through the PR, we think it's Okay that the commands are not avail in Command Palette. As we might have more commands avail in the Find Widget and maybe more places using Find (or just Webview), adding all commands to Command Palette may make it query a bit confusing. Merge it and I'll tweak the code when necessary. |
@rebornix |
@cleidigh can you elaborate more on this? We played with the bits and the Find Widget in Editor works as usual, we didn't want to change the behavior of it, right? |
@rebornix I will redo testing tomorrow to see if I can reproduce. I apologize if I didn't make this clear before , I was expecting to discuss it along with the other issues. I will post my results as soon as possible tomorrow. I am also hoping I can help out more on further re- factoring ! |
@rebornix Steps to reproduce (simplest method)
One "fix": Add context requirement to ShowSimpleFind (editor not focused) const showWidgetSimpleFindCommand = new ShowWidgetSimpleFindCommand({ This does one good thing and one bad thing:
If we had a ContextOr operation we could 'Or' all simpleFind contexts for the show command. I am frustrated I did not detect this before... |
@rebornix
I also added an editor focused check for simpleFind next/previous. Without a key binding comparison, let me know if either of these look good and I will do a new PR (I don't think I can use this one?) |
Revert "Use simpleFind.xyz for simpleFind command IDS" This reverts commit 9066eed. Revert "Review cleanup" This reverts commit c0a2180. Revert "SimpleFindWidget Re-Factor next,previous,history, single global commands Cleanup1" This reverts commit 1a26638. Revert "Working SimpleFind Service, isolation - pre- cleanup" This reverts commit bd8f5eb. Revert "Reveal Find on find n/p, add delayed update history" This reverts commit c586e52. Revert "Hide input focus tracker, cleanup" This reverts commit 27f4523. Revert "simpleFind Add next,previous,history fix" This reverts commit b69d45b.
@alexandrudima Will determine best fix with group. |
The third possible fix is to reintroduce Terminal: Focus simpleFind and ExtensionEditor, WebView as well. Let me know how I can help fix this. |
@rebornix
Other options:
|
@rebornix
@Tyriar
@mjbvz
Replaced PR SimpleFindWidget Add next,previous,history: Fixes #29708 #29661 #32074
Of course the last five percent was all the work
The need for a new context for FindInput Focused was somewhat messy
Had to touch more files than expected, was necessary as there are four clients
Re-FactoringTheFindWidget for common use everywhere will take quite a bit of worksince it's so intertwined with the editor
Hopefully this is useful until we re- factor TheWidget
Fixes Find: No find history #29708 No next and previous keyboard shortcuts for Find widget in Integrated Terminal #29661 also services the modified simpleFindWidget to all users
--