Skip to content

Conversation

@vzarytovskii
Copy link
Member

@vzarytovskii vzarytovskii commented Nov 23, 2021

Fix for #12083, only happens when namespace is on the 1st line of the document, because of this (ctx.Pos.Line = 1 here):

| ScopeKind.Namespace ->
// for namespaces the start line is start line of the first nested entity
if ctx.Pos.Line > 1 then
[0..ctx.Pos.Line - 1]
|> List.mapi (fun i line -> i, getLineStr line)
|> List.tryPick (fun (i, lineStr) ->
if lineStr.StartsWithOrdinal("namespace") then Some i
else None)
|> function
// move to the next line below "namespace" and convert it to F# 1-based line number
| Some line -> line + 2
| None -> ctx.Pos.Line
else 1

Probably can be simplified with removing the codnition alltogether.

I've tested it on:

  • namespace on 1st line
  • namespace is not on 1st line
  • with existing opens
  • without opens
  • without namespace.

Copy link
Contributor

@cartermp cartermp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@vzarytovskii vzarytovskii changed the title Fix adding new opens when namespace is 1st line Fix adding new opens when namespace declaration is on 1st line Nov 23, 2021
@vzarytovskii vzarytovskii merged commit 657a53a into dotnet:main Nov 24, 2021
@vzarytovskii vzarytovskii deleted the fix-12083 branch November 24, 2021 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

F# Error When Adding suggested open is added on top of namespace and this breakes compilation

3 participants