Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Establishing hidden context around edited (Typescript/Javascript) code #1439

Closed
zxti opened this issue May 10, 2019 · 1 comment
Closed

Establishing hidden context around edited (Typescript/Javascript) code #1439

zxti opened this issue May 10, 2019 · 1 comment
Labels
feature-request Request for new features or functionality typescript
Milestone

Comments

@zxti
Copy link

zxti commented May 10, 2019

monaco-editor version: 0.17.0
Browser: Chrome 74.0.3729.131
OS: MacOS 10.14.4

Steps or JS usage snippet reproducing the issue:

I'm trying to build a Typescript/Javascript expression editor (e.g., as the input box for a console/REPL, or for use in various places in a dev tool), where...

  1. a number of variables are provided as part of some existing environment, without being explicitly imported from anywhere.
  2. the expression can be of some expected type, e.g. a particular interface, so you should get completions for members of that interface, as well as type-checking.

I know that (1) can be addressed by addExtraLib, but since there is at most one globally shared instance of Monaco's language services among all editors, this means this may interfere with other edtors, such as those full code files that are open for editing. addExtraLib also doesn't help with (2).

I believe building this would be easy with setHiddenAreas, but I haven't been able to get it to work. See this sandbox—if you keep backspacing from the end to the start, and past the start, you get:

errors.ts:22 Uncaught Error: Not supported

Error: Not supported
    at e.getModelColumnOfViewPosition (splitLinesCollection.ts:990)
    at e.convertViewPositionToModelPosition (splitLinesCollection.ts:733)
    at e.convertViewRangeToModelRange (splitLinesCollection.ts:111)
    at t.getValueInRange (viewModelImpl.ts:569)
    at Object.getValueInRange (textAreaHandler.ts:163)
    at Function.e.fromEditorSelection (textAreaState.ts:251)
    at Object.getScreenReaderContent (textAreaHandler.ts:232)
    at a.writeScreenReaderContent (textAreaInput.ts:484)
    at t.onCursorStateChanged (textAreaHandler.ts:404)
    at t.handleEvents (viewEventHandler.ts:103)
    at e._doConsumeQueue (viewEventDispatcher.ts:88)
    at viewEventDispatcher.ts:71
    at H (viewImpl.ts:582)
    at t._renderOnce (viewImpl.ts:359)
    at e._eventHandlerGateKeeper (viewImpl.ts:111)
    at e.consumeQueue (viewEventDispatcher.ts:67)
    at e.emitMany (viewEventDispatcher.ts:62)
    at viewImpl.ts:142
    at viewEvents.ts:394
    at t._emit (viewEvents.ts:352)
    at t._endEmit (viewEvents.ts:344)
    at t._emitStateChangedIfNecessary (cursor.ts:400)
    at t.trigger (cursor.ts:538)
    at t.executeCommands (codeEditorWidget.ts:1005)
    at t.e.DeleteLeft.r.registerEditorCommand.t.runCoreEditingCommand (coreCommands.ts:1634)
    at t.runEditorCommand (coreCommands.ts:1542)
    at editorExtensions.ts:165
    at e.invokeFunction (instantiationService.ts:60)
    at t.invokeWithinContext (codeEditorWidget.ts:359)
    at t.runCommand (editorExtensions.ts:158)
    at handler (editorExtensions.ts:90)
    at e.invokeFunction (instantiationService.ts:60)
    at e.executeCommand (simpleServices.ts:185)
    at t._doDispatch (abstractKeybindingService.ts:173)
    at t._dispatch (abstractKeybindingService.ts:132)
    at HTMLDivElement.<anonymous> (simpleServices.ts:211)
    at errors.ts:22

And various other issues, e.g. select-all and delete causes the cursor to disappear from Monaco. And, of course, it's not part of the supported API (or else this issue would be a bug report).

After digging through past issues, I also came across this suggestion #170 (comment), which says to fork monaco-typescript. Is this still the best approach for what I'm seeking? Are there any examples or guidance as to the changes needed?

@zxti zxti changed the title Establishing hidden context around edited code Establishing hidden context around edited (Typescript/Javascript) code May 10, 2019
@alexdima alexdima added typescript feature-request Request for new features or functionality labels Dec 11, 2019
@alexdima alexdima added this to the Backlog milestone Dec 11, 2019
@zxti
Copy link
Author

zxti commented May 1, 2021

I've since gotten setHiddenAreas working fine in later Monaco.

@zxti zxti closed this as completed May 1, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality typescript
Projects
None yet
Development

No branches or pull requests

2 participants