@krassowski/jupyterlab_go_to_definition
Version:
Jump to definition of a variable or function in JupyterLab
31 lines • 980 B
JavaScript
const DB_ENTRY = 'jumpy_history';
export class JumpHistory {
constructor(model_db) {
this.model_db = model_db;
}
ensure_history_is_ready() {
if (this.jump_history === undefined) {
if (this.model_db.has(DB_ENTRY)) {
this.jump_history = this.model_db.get(DB_ENTRY);
}
else {
this.jump_history = this.model_db.createList(DB_ENTRY);
}
}
}
store(position) {
this.ensure_history_is_ready();
this.jump_history.push(JSON.stringify(position));
}
recollect() {
this.ensure_history_is_ready();
if (this.jump_history.length === 0) {
return;
}
let last_position = this.jump_history.get(this.jump_history.length - 1);
// being lazy here - undo addition instead of removal ;)
this.jump_history.undo();
return JSON.parse(last_position);
}
}
//# sourceMappingURL=history.js.map