mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
fix search action (#14937)
* fix search action * remove book version from book tree item
This commit is contained in:
@@ -316,7 +316,7 @@ export class BookTocManager implements IBookTocManager {
|
|||||||
* @param section The section that's been moved.
|
* @param section The section that's been moved.
|
||||||
* @param book The target book.
|
* @param book The target book.
|
||||||
*/
|
*/
|
||||||
async moveSectionFiles(section: BookTreeItem, book: BookTreeItem): Promise<void> {
|
async moveSectionFiles(section: BookTreeItem, bookItem: BookTreeItem): Promise<void> {
|
||||||
const uri = path.posix.join(path.posix.sep, path.relative(section.rootContentPath, section.book.contentPath));
|
const uri = path.posix.join(path.posix.sep, path.relative(section.rootContentPath, section.book.contentPath));
|
||||||
let moveFile = path.join(path.parse(uri).dir, path.parse(uri).name);
|
let moveFile = path.join(path.parse(uri).dir, path.parse(uri).name);
|
||||||
let fileName = undefined;
|
let fileName = undefined;
|
||||||
@@ -349,9 +349,9 @@ export class BookTocManager implements IBookTocManager {
|
|||||||
this.cleanUp(path.dirname(section.book.contentPath));
|
this.cleanUp(path.dirname(section.book.contentPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (book.version === BookVersion.v1) {
|
if (bookItem.book.version === BookVersion.v1) {
|
||||||
// here we only convert if is v1 because we are already using the v2 notation for every book that we read.
|
// here we only convert if is v1 because we are already using the v2 notation for every book that we read.
|
||||||
this.newSection = convertTo(book.version, this.newSection);
|
this.newSection = convertTo(bookItem.book.version, this.newSection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,9 +385,9 @@ export class BookTocManager implements IBookTocManager {
|
|||||||
fileName = fileName === undefined ? filePath.name : path.parse(fileName).name;
|
fileName = fileName === undefined ? filePath.name : path.parse(fileName).name;
|
||||||
this.newSection.file = path.posix.join(path.posix.sep, fileName);
|
this.newSection.file = path.posix.join(path.posix.sep, fileName);
|
||||||
this.newSection.title = file.book.title;
|
this.newSection.title = file.book.title;
|
||||||
if (book.version === BookVersion.v1) {
|
if (book.book.version === BookVersion.v1) {
|
||||||
// here we only convert if is v1 because we are already using the v2 notation for every book that we read.
|
// here we only convert if is v1 because we are already using the v2 notation for every book that we read.
|
||||||
this.newSection = convertTo(book.version, this.newSection);
|
this.newSection = convertTo(book.book.version, this.newSection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ export class BookTreeItem extends vscode.TreeItem {
|
|||||||
private _uri: string | undefined;
|
private _uri: string | undefined;
|
||||||
private _previousUri: string;
|
private _previousUri: string;
|
||||||
private _nextUri: string;
|
private _nextUri: string;
|
||||||
public readonly version: BookVersion;
|
|
||||||
public command: vscode.Command;
|
public command: vscode.Command;
|
||||||
public resourceUri: vscode.Uri;
|
public resourceUri: vscode.Uri;
|
||||||
private _rootContentPath: string;
|
private _rootContentPath: string;
|
||||||
@@ -52,7 +51,6 @@ export class BookTreeItem extends vscode.TreeItem {
|
|||||||
if (book.type === BookTreeItemType.Book) {
|
if (book.type === BookTreeItemType.Book) {
|
||||||
this.collapsibleState = book.treeItemCollapsibleState;
|
this.collapsibleState = book.treeItemCollapsibleState;
|
||||||
this._sections = book.page;
|
this._sections = book.page;
|
||||||
this.version = book.version;
|
|
||||||
if (book.isUntitled) {
|
if (book.isUntitled) {
|
||||||
this.contextValue = BookTreeItemType.providedBook;
|
this.contextValue = BookTreeItemType.providedBook;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ export class BookTreeViewProvider implements vscode.TreeDataProvider<BookTreeIte
|
|||||||
public async searchJupyterBooks(treeItem?: BookTreeItem): Promise<void> {
|
public async searchJupyterBooks(treeItem?: BookTreeItem): Promise<void> {
|
||||||
let folderToSearch: string;
|
let folderToSearch: string;
|
||||||
if (treeItem && treeItem.sections !== undefined) {
|
if (treeItem && treeItem.sections !== undefined) {
|
||||||
folderToSearch = treeItem.uri ? getContentPath(treeItem.version, treeItem.book.root, path.dirname(treeItem.uri)) : getContentPath(treeItem.version, treeItem.book.root, '');
|
folderToSearch = treeItem.uri ? getContentPath(treeItem.book.version, treeItem.book.root, path.dirname(treeItem.uri)) : getContentPath(treeItem.book.version, treeItem.book.root, '');
|
||||||
} else if (this.currentBook && !this.currentBook.isNotebook) {
|
} else if (this.currentBook && !this.currentBook.isNotebook) {
|
||||||
folderToSearch = path.join(this.currentBook.contentFolderPath);
|
folderToSearch = path.join(this.currentBook.contentFolderPath);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export class BookTrustManager implements IBookTrustManager {
|
|||||||
let trustableBookPaths = this.getTrustableBookPaths();
|
let trustableBookPaths = this.getTrustableBookPaths();
|
||||||
let hasTrustedBookPath: boolean = treeBookItems
|
let hasTrustedBookPath: boolean = treeBookItems
|
||||||
.filter(bookItem => trustableBookPaths.some(trustableBookPath => trustableBookPath === path.join(bookItem.book.root, path.sep)))
|
.filter(bookItem => trustableBookPaths.some(trustableBookPath => trustableBookPath === path.join(bookItem.book.root, path.sep)))
|
||||||
.some(bookItem => normalizedNotebookUri.startsWith(bookItem.version === BookVersion.v1 ? path.join(bookItem.book.root, 'content', path.sep) : path.join(bookItem.book.root, path.sep)));
|
.some(bookItem => normalizedNotebookUri.startsWith(bookItem.book.version === BookVersion.v1 ? path.join(bookItem.book.root, 'content', path.sep) : path.join(bookItem.book.root, path.sep)));
|
||||||
let isNotebookTrusted = hasTrustedBookPath && this.books.some(bookModel => bookModel.getNotebook(normalizedNotebookUri));
|
let isNotebookTrusted = hasTrustedBookPath && this.books.some(bookModel => bookModel.getNotebook(normalizedNotebookUri));
|
||||||
return isNotebookTrusted;
|
return isNotebookTrusted;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user