Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix whitespace sensitiveness, add more tests
  • Loading branch information
vasily-kirichenko committed Dec 16, 2017
commit 3673d6644162476212aadfc3636ff52efd78fc29
6 changes: 3 additions & 3 deletions src/fsharp/service/ServiceUntypedParse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ module UntypedParseImpl =
let g = m.Groups.["attribute"]
let col = pos.Column - g.Index
if col >= 0 && col < g.Length then
let str = g.Value.Substring(0, col) // cut other rhs attributes
let str = g.Value.Substring(0, col).TrimStart() // cut other rhs attributes
let str = cutLeadingAttributes str
if isLongIdent str then
Some CompletionContext.AttributeApplication
Expand All @@ -1317,11 +1317,11 @@ module UntypedParseImpl =
match lineStr.LastIndexOf "[<" with
| -1 -> None
| openParenIndex when pos.Column >= openParenIndex + 2 ->
let str = lineStr.[openParenIndex + 2..pos.Column - 1]
let str = lineStr.[openParenIndex + 2..pos.Column - 1].TrimStart()
let str = cutLeadingAttributes str
if isLongIdent str then
Some CompletionContext.AttributeApplication
else None
else None
| _ -> None)

/// Check if we are at an "open" declaration
Expand Down
74 changes: 73 additions & 1 deletion tests/service/ServiceUntypedParseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ type T =
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [< |``() =
"""
[< (* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute;|``() =
"""
[<AnAttribute;(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute; |``() =
"""
Expand All @@ -78,6 +96,15 @@ type T =
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][< |``() =
"""
[<AnAttribute>][< (* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute(|``() =
"""
Expand All @@ -87,6 +114,15 @@ type T =
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute( |``() =
"""
[<AnAttribute( (* marker *)
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute>][<AnAttribute(|``() =
"""
Expand Down Expand Up @@ -116,6 +152,15 @@ type T =
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [< |>]``() =
"""
[< (* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][<|>]``() =
"""
Expand All @@ -126,14 +171,32 @@ type T =
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute; | >]``() =
let ``AttributeApplication completion context at [<AnAttribute>][< |>]``() =
"""
[<AnAttribute>][< (* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute;|>]``() =
"""
[<AnAttribute;(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute; | >]``() =
"""
[<AnAttribute; (* marker *) >]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][<AnAttribute; | >]``() =
"""
Expand Down Expand Up @@ -170,6 +233,15 @@ type T =
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute; AnAttribute( | >]``() =
"""
[<AnAttribute; AnAttribute( (* marker *)>]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute>][<AnAttribute; AnAttribute(| >]``() =
"""
Expand Down