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

Use Cell's index in the notebook as its ID #81

Merged
merged 5 commits into from Mar 1, 2019
Merged

Conversation

jonathanindig
Copy link
Collaborator

Cell ID is now a short and we no longer read execution count. This is possible now due to the changes in #76 which eliminates our need to persist cell IDs in the order they were created.

Addresses #70 as it was due to id space collisions when reading execution count.

@jeremyrsmith
Copy link
Contributor

This is really great!

One condition: if we ever decide to change the identifier type again (i.e. there's complaint about the 32,767 limit on cells in a notebook), we'll make a CellId type alias to use everywhere.

Copy link
Contributor

@jeremyrsmith jeremyrsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't let me comment on the lines you didn't change 😛

Here we're creating a new (JS) NotebookCell with newCell.id which is still a string. Won't this cause inserting a cell to fail? I think the Cell classes need to be updated to deal with the numeric ID (and how to map that to an id attribute for their container element).

this.socket.send(new messages.InsertCell(path, this.globalVersion, this.localVersion++, new messages.NotebookCell(newCell.id, newCell.language, ''), current.id));

@jonathanindig
Copy link
Collaborator Author

This is really great!

One condition: if we ever decide to change the identifier type again (i.e. there's complaint about the 32,767 limit on cells in a notebook), we'll make a CellId type alias to use everywhere.

I like this idea a lot - I renamed a bunch of parameters from id => cellId but I think using a CellId type instead is a much better way to indicate what the parameter is rather than changing its name.

@@ -761,7 +761,7 @@ export class NotebookUI {

this.cellUI.addEventListener('InsertCellAfter', evt => {
const current = this.cellUI.cells[evt.detail.cellId] || this.cellUI.cells[this.cellUI.el.querySelector('.cell-container').id];
const nextId = "Cell" + this.cellUI.cellCount;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremyrsmith As far as I could tell this looked like the only change that needed to be done - not sure if you had anything else in mind when you said

I think the Cell classes need to be updated to deal with the numeric ID (and how to map that to an id attribute for their container element).

I wasn't able to find any other place where we explicitly do stringy things to the cell id but I definitely could've missed something.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... I guess the only other issue is that the ID passed to the cell constructor also ends up as a DOM element ID. For example now we'll have something like <div id="1"> in the DOM. This isn't a legal id in HTML 4, though I guess it now is in HTML 5... but still doesn't seem like a good idea.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok! restored previous html ids :)

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.

None yet

2 participants