mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Fix/prev next links issue (#10523)
* intital test code * added tests * remove commented code * fix for failing tests * reuse exported enum * changes to address comments * add back onVisibility highlight * port highlight fix from Chris * fix tests
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import * as vscode from 'vscode';
|
||||
import * as yaml from 'js-yaml';
|
||||
import { BookTreeItem, BookTreeItemType } from './bookTreeItem';
|
||||
@@ -17,11 +16,10 @@ import { ApiWrapper } from '../common/apiWrapper';
|
||||
|
||||
const fsPromises = fileServices.promises;
|
||||
|
||||
export class BookModel implements azdata.nb.NavigationProvider {
|
||||
export class BookModel {
|
||||
private _bookItems: BookTreeItem[];
|
||||
private _allNotebooks = new Map<string, BookTreeItem>();
|
||||
private _tableOfContentsPath: string;
|
||||
readonly providerId: string = 'BookNavigator';
|
||||
|
||||
private _errorMessage: string;
|
||||
private apiWrapper: ApiWrapper = new ApiWrapper();
|
||||
@@ -32,7 +30,6 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
||||
public readonly isNotebook: boolean,
|
||||
private _extensionContext: vscode.ExtensionContext) {
|
||||
this._bookItems = [];
|
||||
this._extensionContext.subscriptions.push(azdata.nb.registerNavigationProvider(this));
|
||||
}
|
||||
|
||||
public async initializeContents(): Promise<void> {
|
||||
@@ -251,30 +248,6 @@ export class BookModel implements azdata.nb.NavigationProvider {
|
||||
return this._tableOfContentsPath;
|
||||
}
|
||||
|
||||
getNavigation(uri: vscode.Uri): Thenable<azdata.nb.NavigationResult> {
|
||||
let notebook = !this.openAsUntitled ? this._allNotebooks.get(uri.fsPath) : this._allNotebooks.get(path.basename(uri.fsPath));
|
||||
let result: azdata.nb.NavigationResult;
|
||||
if (notebook) {
|
||||
result = {
|
||||
hasNavigation: true,
|
||||
previous: notebook.previousUri ?
|
||||
this.openAsUntitled ? this.getUntitledUri(notebook.previousUri) : vscode.Uri.file(notebook.previousUri) : undefined,
|
||||
next: notebook.nextUri ? this.openAsUntitled ? this.getUntitledUri(notebook.nextUri) : vscode.Uri.file(notebook.nextUri) : undefined
|
||||
};
|
||||
} else {
|
||||
result = {
|
||||
hasNavigation: false,
|
||||
previous: undefined,
|
||||
next: undefined
|
||||
};
|
||||
}
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
|
||||
getUntitledUri(resource: string): vscode.Uri {
|
||||
return vscode.Uri.parse(`untitled:${resource}`);
|
||||
}
|
||||
|
||||
public get errorMessage(): string {
|
||||
return this._errorMessage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user