Monaco-editor: Documentation - how to get the selected text ?

Created on 21 Nov 2017  路  3Comments  路  Source: microsoft/monaco-editor

I'm able to get the text of the editor with
window.editor.getValue()

And I'm able to get the currently selected text-positions with
window.editor.getSelection()

鈥婤ut how do I get the text-value of the currently selected text ?

Like when I have multiple sql statements, select one statement, and press F5 to execute it - I need the actual text ;)

Most helpful comment

Try:

window.editor.getModel().getValueInRange(window.editor.getSelection())

All 3 comments

Try:

window.editor.getModel().getValueInRange(window.editor.getSelection())

Works like a charm.
Thanks !

@kristianoye Thanks It's saved my time

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aarinsmith picture aarinsmith  路  3Comments

inf9144 picture inf9144  路  3Comments

akosyakov picture akosyakov  路  3Comments

poloten4uk picture poloten4uk  路  3Comments

Kedyn picture Kedyn  路  3Comments