Skip to content

Commit 145b4d5

Browse files
authored
Merge pull request #102 from mpilgrem/insertFix
Fix #98 Import identifier insertion line
2 parents 45a1e74 + 318bdd7 commit 145b4d5

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)