Skip to content

Commit c0d3701

Browse files
committed
Update sealed states
1 parent 1740afb commit c0d3701

File tree

4 files changed

+42
-12
lines changed

4 files changed

+42
-12
lines changed

CHANGELOG.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
11
# Change Log
22

3-
All notable changes to the "flutter-plus" extension will be documented in this file.
4-
5-
Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file.
6-
7-
## [Unreleased]
8-
9-
- Initial release
3+
All notable changes to the "flutter-plus" extension will be documented in this file.

package-lock.json

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"displayName": "Flutter Plus",
44
"description": "Extension with various improvements for Flutter",
55
"icon": "assets/logo.png",
6-
"version": "0.6.1",
6+
"version": "0.7.0",
77
"pricing": "Free",
88
"engines": {
99
"vscode": "^1.92.0"
@@ -209,4 +209,4 @@
209209
"@vscode/test-cli": "^0.0.9",
210210
"@vscode/test-electron": "^2.4.0"
211211
}
212-
}
212+
}

src/commands/sealed-states.command.ts

+36-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,41 @@ import * as vscode from 'vscode';
33
import { Uri } from "vscode";
44

55
export const sealedStates = async (uri: Uri) => {
6+
// If no URI is provided, use the active text editor
7+
if (!uri) {
8+
const activeEditor = vscode.window.activeTextEditor;
9+
if (activeEditor) {
10+
uri = activeEditor.document.uri;
11+
} else {
12+
const selectedFiles = await vscode.window.showOpenDialog({
13+
canSelectMany: false,
14+
openLabel: 'Select a Dart file',
15+
filters: {
16+
'Dart Files': ['dart']
17+
}
18+
});
19+
20+
if (!selectedFiles || selectedFiles.length === 0) {
21+
vscode.window.showErrorMessage('No file selected.');
22+
return;
23+
}
24+
25+
uri = selectedFiles[0];
26+
}
27+
}
28+
29+
let document = await vscode.workspace.openTextDocument(uri);
30+
let editor = vscode.window.activeTextEditor;
31+
32+
if (!editor || editor.document.uri.fsPath !== uri.fsPath) {
33+
editor = await vscode.window.showTextDocument(document);
34+
}
35+
36+
if (!editor) {
37+
vscode.window.showErrorMessage('Could not open the file.');
38+
return;
39+
}
40+
641
// Extract the file name in a cross-platform way
742
const fileName = path.basename(uri.fsPath, '.dart');
843
if (!fileName) {
@@ -326,7 +361,7 @@ export const sealedStates = async (uri: Uri) => {
326361
codeBuilder.push('');
327362

328363
// Insert the generated code into the current document
329-
const editor = vscode.window.activeTextEditor;
364+
//const editor = vscode.window.activeTextEditor;
330365
if (editor) {
331366
editor.insertSnippet(new vscode.SnippetString(codeBuilder.join('\n')));
332367
/* editor.edit(editBuilder => {

0 commit comments

Comments
 (0)