Skip to content

Infoview DocumentPosition should be a context #197

Closed

Description

@EdAyers

Currently in the infoview code, every component is passing the pos : DocumentPosition prop up through the component hierarchy. I think it would make a lot of sense to make this a React context instead.

Activity

  1. gebner commented on Jun 17, 2022

    @gebner
    Member

    I'm not sure if this is such a good idea. We have a lot of different positions floating around.

    1. The cursor position in the editor.
    2. The position of the current info (which may be different from the cursor position if it's pinned).
    3. The position of the data shown in the info (which may lag behind the info position when the cursor is moved).
    4. The position used for RPC queries.
    5. The position of the diagnostic message / term goal / widget.

    It goes without saying that all of these can be different. I vaguely recall that we've had some issues mixing up 2 and 3 but I can't find it right now.

  2. lovettchris commented on Jun 20, 2022

    @lovettchris

    I agree with Gabriel, I think "pinning" shows an example where a react component needs it's own local "pos" that is not in a shared context. You see this in Infos.tsx where the pos being passed down to the component is conditionally coming from the curLoc state or the pinnedPoss state. Infos is also listening to the ec.events.changedCursorLocation event so it can update when the current location is changed. AllMessages is also an example of a React component in the info view that does not use the cursor location at all.

    image

    I am curious about the naming of pinnedPoss and setPinnedPoss. I would have named these pinnedPos and setPinnedPos. I'm not sure what the second s at the and of those names represents exactly... it's not like it is plural positions or anything... so a bit confusing to me? Or is it plural because of the pinKey.current refcount?

  3. EdAyers commented on Jun 21, 2022

    @EdAyers
    ContributorAuthor

    There are different poses flying around but once you are inside the body of InfoDisplay there is only one pos. so the proposal would be to add pos as a context there.

  4. gebner commented on Jun 21, 2022

    @gebner
    Member

    once you are inside the body of InfoDisplay there is only one pos

    Inside of InfoDisplay you still have the positions (2)-(5) from my list.

  5. EdAyers commented on Jun 21, 2022

    @EdAyers
    ContributorAuthor

    ok within GoalUI, but also MessageView does its own thing with positions and can ignore the context. Eg the context could be called InfoDisplayPosContext.

    I'm going to close because also this doesn't matter.

  6. added a commit that references this issue on Jun 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions