question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

provideSelectionRanges is not invoked when user select a token by double clicking on it

See original GitHub issue

I need to override something related to token selection and i encounter provideSelectionRanges.

provideSelectionRanges is not invoked when we select a token by double clicking on it.

Please see the code snippet below

`

monaco.languages.register({ id: 'mySpecialLanguage' });

monaco.languages.registerSelectionRangeProvider('mySpecialLanguage', {
    provideSelectionRanges: function (model, positions, token) {
    
            console.log('i am provideSelectionRanges');
            const position = positions[0];
            const word = model.getWordAtPosition(position);
    
            console.log('selection range provider word is: ', word);
            return null
   }
});

monaco.editor.create(document.getElementById("container"), {
    value: '\n\nHover over this text',
    language: 'mySpecialLanguage'
});

` What am i doing wrong or is there any another provider which will help me override things related to token selections.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
alexdimacommented, May 12, 2021

@abhishekthakurak You can listen to selection changes and then change the editor’s selection to be something else using editor.setSelection. This method is documented at https://microsoft.github.io/monaco-editor/api/index.html and is available in the editor’s .d.ts files.

0reactions
abhishekthakurakcommented, May 12, 2021

@alexdima i think this will work thanks for the answer

Read more comments on GitHub >

github_iconTop Results From Across the Web

ISelection - ngx-monaco-editor-demo documentation
To not automatically create a model, use `model: null`. ... Should the corresponding line be selected when clicking on the line number? *...
Read more >
VS Code API | Visual Studio Code Extension API
VS Code API is a set of JavaScript APIs that you can invoke in your Visual Studio Code extension. This page lists all...
Read more >
Can't Double-Click : r/FoundryVTT - Reddit
So you have to click once to select the token, then double click it to open the sheet.
Read more >
monaco-editor - UNPKG
CancellationToken ); ... Therefore `Uri#fsPath` exists - it's sugar to ease working ... 1066, * To not create automatically a model, use `model:...
Read more >
https://raw.githubusercontent.com/Microsoft/vscode...
*Note* that * this does not mean the document will be saved to disk, use ... An optional function that is invoked whenever...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found