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

Da#302 testing fixes in terminal change indexes problem and workbench save issue #303

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/commands/indexes/openIndexInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ import { MemFS } from "../../util/fileSystemProvider";
import IndexNode from "../../model/IndexNode";

export const openIndexInfo = async (indexNode: IndexNode, memFs: MemFS) => {
try {
const uri = vscode.Uri.parse(
`couchbase:/${indexNode.bucketName}/${indexNode.scopeName}/Indexes/${indexNode.indexName}.n1ql`
);
memFs.writeFile(
uri,
Buffer.from(indexNode.data),
{ create: true, overwrite: true }
);
const document = await vscode.workspace.openTextDocument(uri);
await vscode.window.showTextDocument(document, { preview: false });
return true;
} catch (err: any) {
logger.error("Failed to open index information");
logger.debug(err);
}
try {
const uri = vscode.Uri.parse(
`couchbase:/${indexNode.bucketName}/${indexNode.scopeName}/Indexes/${indexNode.indexName}.sqlpp`
);
memFs.writeFile(
uri,
Buffer.from(indexNode.data),
{ create: true, overwrite: true }
);
const document = await vscode.workspace.openTextDocument(uri);
await vscode.window.showTextDocument(document, { preview: false });
return true;
} catch (err: any) {
logger.error("Failed to open index information");
logger.debug(err);
}
};
1 change: 1 addition & 0 deletions src/commands/queryHistory/applyQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const applyQuery = async (query: IQuery) => {
return;
}
const activeTextEditor = vscode.window.activeTextEditor;
activeTextEditor?.document.save();
AayushTyagi1 marked this conversation as resolved.
Show resolved Hide resolved
if (
activeTextEditor &&
activeTextEditor.document.languageId === "SQL++"
Expand Down
2 changes: 1 addition & 1 deletion src/model/IndexDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class IndexDirectory implements INode {
this.connection,
this.scopeName,
this.bucketName,
`${query.name.substring(1)}_${(query.collectionName ?? "")}`,
`${query.name[0] === '#' ? query.name.substring(1) : query.name}${(query.collectionName ? ("_" + query.collectionName) : "")}`,
getIndexDefinition(query),
vscode.TreeItemCollapsibleState.None
);
Expand Down
3 changes: 2 additions & 1 deletion src/workbench/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ export default class UntitledSqlppDocumentService {
});

const document = await vscode.workspace.openTextDocument(uri);
document.save();
await vscode.window.showTextDocument(document, { preview: false });
return vscode.workspace.openTextDocument(uri);
return document;
}

/**
Expand Down
5 changes: 3 additions & 2 deletions src/workbench/queryWorkbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export class QueryWorkbench {
}
// Get the active text editor
const activeTextEditor = vscode.window.activeTextEditor;
activeTextEditor?.document.save();
AayushTyagi1 marked this conversation as resolved.
Show resolved Hide resolved
if (activeTextEditor && activeTextEditor.document.languageId === "SQL++") {
// Get the text content of the active text editor.
const query = activeTextEditor.selection.isEmpty ? activeTextEditor.document.getText() : activeTextEditor.document.getText(activeTextEditor.selection);
Expand Down Expand Up @@ -77,7 +78,7 @@ export class QueryWorkbench {
size: resultSize ? (resultSize > 1000 ? (resultSize / 1000).toFixed(2) + " KB" : resultSize + " Bytes") : ""
};
const explainPlan = JSON.stringify(result?.meta.profile.executionTimings);
await workbenchWebviewProvider.setQueryResult(
workbenchWebviewProvider.setQueryResult(
JSON.stringify(result?.rows),
queryStatusProps,
explainPlan
Expand Down Expand Up @@ -118,7 +119,7 @@ export class QueryWorkbench {
numDocs: "-",
size: "-",
};
await workbenchWebviewProvider.setQueryResult(
workbenchWebviewProvider.setQueryResult(
JSON.stringify(errorArray),
queryStatusProps,
null
Expand Down
1 change: 0 additions & 1 deletion src/workbench/workbenchWebviewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export class WorkbenchWebviewProvider implements vscode.WebviewViewProvider {
this._view.webview.html = getWebviewContent(reactAppUri, this._context);
const isDarkTheme: boolean = vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark;
this._view?.webview.postMessage({ command: "theme", isDarkTheme });
this._view?.onDidDispose(() => Memory.state.update(Constants.QUERY_RESULT, null));
this._view?.onDidChangeVisibility(() => {
if (Memory.state.get<IQueryResultProps>(Constants.QUERY_RESULT)) {
this.sendQueryResult(JSON.stringify([{ "status": "Loading last executed result" }]), { queryStatus: QueryStatus.Running }, null);
Expand Down