-
Notifications
You must be signed in to change notification settings - Fork 393
highlight the currently open notebook in NotebookList #1420
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
base: master
Are you sure you want to change the base?
Conversation
* Will only return a nonempty string for n >= 1. | ||
* E.g. if called with "hello/world" where n = 1 and pattern = "/", will return "hello" | ||
*/ | ||
export function getUpToNthOccurrence(str: string, n: number, pattern: string): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this different from the optional limit
parameter on split
? https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split#syntax
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's different? What I was specifically looking for (and which I didn't make very clear from the comment) is to also return the pattern in the string. Traversing the file tree, I needed to get everything up to a certain slash, so for example, wanting to get the first few folders in a path like root/folder/inner-folder/file.ipynb
, we might want root/folder
or root/folder/inner-folder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.....oops, yeah, that does exactly what I want. Will refactor, thank you!
if (!currentState || !isBranch(currentState) || !currentState.children[piece]) { | ||
currentUpdate.fullPath = currentPath; | ||
currentUpdate.value = piece; | ||
currentUpdate.isOrHasCurrentNotebook = currentNotebook === path; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does currentNotebook
have to be updated here? I wonder whether it'd be updated anyways after the path is added (doesn't the state update selecting the current notebook happen after the state update adding a new path? Or am I misremembering?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just stepping through in devtools, I'm seeing some instances where branchHandler.addPath
gets called after branchHandler.updateCurrentNotebook
- not sure where the logic for ordering the state updates lives but it doesn't seem like the behavior is always "add path and then update current notebook."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Under what situation do you see that addPath gets called after updateCurrentNotebook? I wasn't able to reproduce.
The last step of the process to create a new notebook is to select it so I think things should happen in the order I mentioned earlier: https://github.com/polynote/polynote/blob/megan/highlight-current-notebook/polynote-frontend/polynote/messaging/dispatcher.ts#L379
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to kind of repro when renaming a notebook, I think. But it's hard to tell because we have a bug with that 😅 #1422
If that's the only way to repro I think we should fix that problem: in general, selecting the current notebook should be the very last thing that happens; and notebook shouldn't be selected before it "exists" if that makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like when reopening the current notebooks (e.g. create a notebook and refresh the page with the notebook still open), the frontend is loading the notebooks and then also getting a message from the server (of type ListNotebooks
), triggering another state update and causing addPath to get called again.
Thanks for the screenshot! Can you show how the "target" button works? (maybe a gif or movie?) |
Good call, just added to the original PR description |
Thanks! I see there's both a gray highlight and a blue highlight. What is the difference between the two? Do we need both? |
The blue highlight is the focus, which I think should probably be distinct from being highlighted (primarily for the use case of using arrow keys to navigate the file tree)? I was using .focus to scroll to the current notebook upon clicking the crosshairs, but I agree that it's kind of weird. How do you feel about this instead? There's still a brief blue flash when initially selecting the notebook, unfortunately. |
Huh, I totally forgot we supported using the arrow keys to navigate the file tree 😅 That looks great to me! I even think the blue flash makes sense. |
isOrHasCurrentNotebook: false, | ||
children: {} | ||
}); | ||
currentNotebookPath = "nonsense.ipynb"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'm still suspicious there's something weird going on with the state updates and handling elsewhere but I think this is fine to merge and we'll untangle that when we come to it.
Thanks and sorry for the delay in reviewing!
closes #1417