Skip to content

input: add lsp provider setters; setters set _pending_update so LSP refreshes on next render#2491

Open
ScottCUSA wants to merge 1 commit into
longbridge:mainfrom
ScottCUSA:add-input-lsp-provider-setters
Open

input: add lsp provider setters; setters set _pending_update so LSP refreshes on next render#2491
ScottCUSA wants to merge 1 commit into
longbridge:mainfrom
ScottCUSA:add-input-lsp-provider-setters

Conversation

@ScottCUSA

Copy link
Copy Markdown
Contributor

Closes #2476

Description

The InputState.lsp providers fields are public, but setting them does not refresh the Lsp state until the next time the InputState's text is changed. This adds setter methods to the InputState. Each setter assigns it's provider, then set's the _pending_update flag so that the Lsp state is refreshed on the next render.

Break Changes

No Breaking Changes. Added public InputState methods.

How to Test

Create an InputState. Add use the setters to update the hover provider, color provider, etc. and watch the Input refresh as expected.

ex:

        let snapshot = self.hover_snapshot(cx);
        let inputs = self.token_inputs(cx);
        for input in &inputs {
            let snapshot = snapshot.clone();
            input.update(cx, |state, cx| {
                state.set_lsp_hover_provider(
                    Some(Rc::new(TokenHoverProvider {
                        snapshot: snapshot.clone(),
                    })),
                    cx,
                );
                state.set_lsp_document_color_provider(
                    Some(Rc::new(TokenColorProvider {
                        snapshot: snapshot.clone(),
                    })),
                    cx,
                );
            });
        }
  • Attach an LSP provider at runtime via a setter; confirm semantic highlighting / document colors refresh without
    editing text
  • Swap providers at runtime; confirm old results clear and new provider runs
  • Direct field assignment still compiles, but perhaps the Lsp fields visibility could be changed in the future

Checklist

  • I have read the CONTRIBUTING document and followed the guidelines.
  • Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate.
  • Passed cargo run for story tests related to the changes.
  • Tested macOS, Windows and Linux platforms performance (if the change is platform-specific)

Setters flag _pending_update so LSP refreshes on next render after runtime provider changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow user to set Lsp providers and refresh the Lsp state after the InputState is created

1 participant