mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Fix not numbered inconsistency (#14269)
* fix not numbered field * fix for adding extra field and removing it from sections * use const for variable * use spread operator to create new object * address pr comments * change function name and simplify * Add comment and put the initializeContents in the finally block
This commit is contained in:
@@ -343,8 +343,10 @@ export class BookTocManager implements IBookTocManager {
|
|||||||
|
|
||||||
if (this._sourceBook) {
|
if (this._sourceBook) {
|
||||||
const sectionTOC = this._sourceBook.bookItems[0].findChildSection(notebook.uri);
|
const sectionTOC = this._sourceBook.bookItems[0].findChildSection(notebook.uri);
|
||||||
|
if (sectionTOC) {
|
||||||
this.newSection = sectionTOC;
|
this.newSection = sectionTOC;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
fileName = fileName === undefined ? notebookPath.name : path.parse(fileName).name;
|
fileName = fileName === undefined ? notebookPath.name : path.parse(fileName).name;
|
||||||
this.newSection.file = path.sep.concat(fileName).replace(/\\/g, '/');
|
this.newSection.file = path.sep.concat(fileName).replace(/\\/g, '/');
|
||||||
this.newSection.title = notebook.book.title;
|
this.newSection.title = notebook.book.title;
|
||||||
|
|||||||
@@ -225,11 +225,11 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
await targetBook.initializeContents();
|
await targetBook.initializeContents();
|
||||||
|
} finally {
|
||||||
if (sourceBook && sourceBook.bookPath !== targetBook.bookPath) {
|
if (sourceBook && sourceBook.bookPath !== targetBook.bookPath) {
|
||||||
// refresh source book model to pick up latest changes
|
// refresh source book model to pick up latest changes
|
||||||
await sourceBook.initializeContents();
|
await sourceBook.initializeContents();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
this._onDidChangeTreeData.fire(undefined);
|
this._onDidChangeTreeData.fire(undefined);
|
||||||
// even if it fails, we still need to watch the toc file again.
|
// even if it fails, we still need to watch the toc file again.
|
||||||
if (sourceBook) {
|
if (sourceBook) {
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export function convertFrom(version: string, section: JupyterBookSection): Jupyt
|
|||||||
divider: (section as IJupyterBookSectionV1).divider,
|
divider: (section as IJupyterBookSectionV1).divider,
|
||||||
header: (section as IJupyterBookSectionV1).header,
|
header: (section as IJupyterBookSectionV1).header,
|
||||||
external: (section as IJupyterBookSectionV1).external,
|
external: (section as IJupyterBookSectionV1).external,
|
||||||
numbered: !(section as IJupyterBookSectionV1).not_numbered,
|
numbered: (section as IJupyterBookSectionV1).not_numbered !== undefined ? !(section as IJupyterBookSectionV1).not_numbered : undefined,
|
||||||
not_numbered: undefined
|
not_numbered: undefined
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -56,8 +56,22 @@ export function convertFrom(version: string, section: JupyterBookSection): Jupyt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used by JupyterBookSection to convert it's numbered property to
|
||||||
|
* not_numberered.
|
||||||
|
* Or it's used by an JupyterBookSectionV1 to make a deep copy of an object.
|
||||||
|
* @param section The section that'll be converted.
|
||||||
|
*/
|
||||||
|
function convertNotNumbered(section: JupyterBookSection): boolean | undefined {
|
||||||
|
if (section.numbered !== undefined) {
|
||||||
|
return !section.numbered;
|
||||||
|
}
|
||||||
|
return section.not_numbered !== undefined ? section.not_numbered : undefined;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the JupyterSection to either Jupyter Book v1 or v2.
|
* Converts the JupyterSection to either Jupyter Book v1 or v2.
|
||||||
|
* This method is also used to make a deep copy of a section object.
|
||||||
* @param version Version of the section that will be converted
|
* @param version Version of the section that will be converted
|
||||||
* @param section The section that'll be converted.
|
* @param section The section that'll be converted.
|
||||||
*/
|
*/
|
||||||
@@ -68,7 +82,7 @@ export function convertTo(version: string, section: JupyterBookSection): Jupyter
|
|||||||
temp.title = section.title;
|
temp.title = section.title;
|
||||||
temp.url = section.url ? section.url : section.file;
|
temp.url = section.url ? section.url : section.file;
|
||||||
temp.expand_sections = section.expand_sections;
|
temp.expand_sections = section.expand_sections;
|
||||||
temp.not_numbered = !section.numbered;
|
temp.not_numbered = convertNotNumbered(section);
|
||||||
temp.search = section.search;
|
temp.search = section.search;
|
||||||
temp.divider = section.divider;
|
temp.divider = section.divider;
|
||||||
temp.header = section.header;
|
temp.header = section.header;
|
||||||
@@ -84,7 +98,7 @@ export function convertTo(version: string, section: JupyterBookSection): Jupyter
|
|||||||
newSection.title = section.title;
|
newSection.title = section.title;
|
||||||
newSection.url = section.url ? section.url : section.file;
|
newSection.url = section.url ? section.url : section.file;
|
||||||
newSection.sections = section.sections;
|
newSection.sections = section.sections;
|
||||||
newSection.not_numbered = !section.numbered;
|
newSection.not_numbered = convertNotNumbered(section);
|
||||||
newSection.expand_sections = section.expand_sections;
|
newSection.expand_sections = section.expand_sections;
|
||||||
newSection.search = section.search;
|
newSection.search = section.search;
|
||||||
newSection.divider = section.divider;
|
newSection.divider = section.divider;
|
||||||
|
|||||||
Reference in New Issue
Block a user