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

spahnke picture spahnke  路  26Comments

Raathigesh picture Raathigesh  路  41Comments

jayspadie picture jayspadie  路  16Comments

sinaa picture sinaa  路  26Comments

akosyakov picture akosyakov  路  16Comments