Skip to content

Commit 318bdd7

Browse files
committed
Fix #98 Import identifier insertion line
`moduleLine` is now the first line that is (trimmed) `where` or ends with ` where` or ends with `)where`.
1 parent 45a1e74 commit 318bdd7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/commands/importIdentifier.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ const doImport = async (arg: { mod: string; package: string }): Promise<void> =>
4242
const edit = new vscode.WorkspaceEdit();
4343

4444
const lines = document.getText().split('\n');
45-
const moduleLine = lines.findIndex(line => line.startsWith('module'));
45+
const moduleLine = lines.findIndex(line => {
46+
const lineTrimmed = line.trim();
47+
return lineTrimmed === 'where' || lineTrimmed.endsWith(' where') || lineTrimmed.endsWith(')where');
48+
});
4649
const revInputLine = lines.reverse().findIndex(l => l.startsWith('import'));
4750
const nextInputLine = revInputLine !== -1 ? lines.length - 1 - revInputLine : moduleLine === -1 ? 0 : moduleLine + 1;
4851

0 commit comments

Comments
 (0)