undercover grill
undercover grill

Reputation: 31

Monaco-Editor callback for when a symbol or line number is selected from quickfind

How to add an action opening a dropdown menu in Monaco Editor?

The above post shows how to retrieve IQuickInputService to create a custom quick find. They can show it, populate and then execute code after a user has made a selection, this is what I'm looking for.

Following the example I get, Value: Error: [invokeFunction] unknown service 'quickInputService'

Really though, I just need a callback for when a symbol or line number is selected from quickfind (CTRL+SHIFT+O). I've tried,

editor.getAction('editor.action.gotoLine').run().then((x) => {})

but the callback is instant. Data in my app gets loaded async when you select a symbol or gotoline, I need some sort of callback when this happens.

I've seen people suggest creating an entirely custom widget to handle this. But

The solution in the above post would be idle.

Things I've tried.

editor.onDidChangeCursorPosition(function (e) { console.log(e); })

Clips to the range of the current view, ie if you only have 100 line and symbol is at 400, you get 100 in e.

editor.getAction('editor.action.gotoLine').run().then((x) => {})

Callback runs instantly, I would need it to wait till a user is done picking as in How to add an action opening a dropdown menu in Monaco Editor?

editor.setPosition({ column: 1, lineNumber: 600 });
editor.revealLineInCenter(15);

Clip to the current line count

I've thought about just setting the line count to what I need but that'd be a total of at least 60000+ with a hacky solution and around 500mil for the actual line count.

I checked the OnDid Events and didn't see anything else that looked like it could help.

Monaco editor - onDidBlurEditorText vs onDidBlurEditorWidget Mentions using blurs to detect the user leaving but this doesn't provide info about what was selected

Upvotes: 1

Views: 969

Answers (0)

Related Questions