microsoft / microsoft/monaco-editor
[Feature Request] Get the value at position with specific delimiters
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Context
- This issue is not a bug report. (please use a different template for reporting a bug)
- This issue is not a duplicate of an existing issue. (please use the search to find existing issues)
Description
I have a hover provider and I need to provide dynamic content based on the text I'm hovering. I should only return content, if the text hovered is surrounded by quotes ("), for example "hoverThis" or "hover_this".
My problem is that when doing model.getWordAtPosition(), if the hovered text has word delimiters (for example: "hover.this" or "hover this"), I only get part of the content.
If I do model.findPreviousMatch('"') to get the previous and next quote, the search algorithm will loop to the end/beginning of the whole content and match the incorrect text, and even if it worked, it wouldn't guarantee I'm not hovering a word in between two quoted strings (for example: "one quote" hover >< here and "another quote").
I'm looking for something like: model.getValueAtPosition(position, openDelimiters, closeDelimiters)
to be used in my case like: model.getValueAtPosition(position,['"'], ['"'])
this could also be helpful to find text wrapped in parenthesis or brackets like:
model.getValueAtPosition(position,['[', ('], [']', ')'])
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Start by tracing the model.getWordAtPosition() and model.findPreviousMatch() entry points mentioned in the issue, then examine Monaco's model APIs and delimiter handling. Done means a position-based lookup is specified and implemented for quoted, spaced, dotted, parenthesized, and bracketed text, with verification for those cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100