unisonweb/ui-core

Perspective switch from open definition in specific cases duplicates the FQN

hojberg opened this issue · 0 comments

Steps to reproduce:

  1. Open a definition deep in the tree, say base.data.List.map
  2. Switch perspective to base.data
  3. Use the perspective switch on the open definition (map), which results in base.data.base.data.List.map

Recently I added 2 functions FQN.stripPrefix and FQN.extend that would help solve this problem as the user clicks to change the perspective. This would definitely work, but after talking to @ChrisPenner we think a better solution would be to either construct an absolute name during parse time or get both absolute and the best name, or have both of those fields be served by the backend.

Note that the frontend currently does nothing to re-render a definition with new names when a perspective changes. This behavior should remain—trying to construct best names in the frontend is not the behavior we want. Alternatively we could re-fetch open definitions from the backend, but that would result in a lot of spinners, and some might not resolve with the new perspective (maybe this is ok?). Another alternative is to always clear the workspace on perspective change, though this is likely going to be jarring for the user.