Skip to content

Commit 72b664a

Browse files
committed
Avoid PRECONDITION_FAILURE on editing an empty file
Fix #1435
1 parent 50b29c2 commit 72b664a

File tree

5 files changed

+194
-0
lines changed

5 files changed

+194
-0
lines changed

source/ada/lsp-ada_completions-keywords.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ package body LSP.Ada_Completions.Keywords is
4646
begin
4747
if Filter.Is_End_Label or else
4848
Filter.Is_Numeric_Literal or else
49+
Node.Is_Null or else
4950
not Libadalang.Common.Is_Trivia (Prev)
5051
then
5152
-- Propose keyword completion if we are not within an end label
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
project Default is
2+
end Default;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
--
2+
--
Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
[
2+
{
3+
"comment": ["test PRECONDITION_FAILURE on an empty file editing"]
4+
},
5+
{
6+
"start": {
7+
"cmd": ["${ALS}"]
8+
}
9+
},
10+
{
11+
"send": {
12+
"request": {
13+
"jsonrpc": "2.0",
14+
"id": 1,
15+
"method": "initialize",
16+
"params": {
17+
"processId": 199714,
18+
"rootUri": "$URI{.}",
19+
"capabilities": {
20+
"workspace": {
21+
"applyEdit": true
22+
},
23+
"textDocument": {
24+
"completion": {
25+
"completionItem": {
26+
"snippetSupport": true,
27+
"documentationFormat": ["markdown", "plaintext"]
28+
}
29+
}
30+
},
31+
"window": {
32+
"workDoneProgress": true
33+
}
34+
}
35+
}
36+
},
37+
"wait": [
38+
{
39+
"jsonrpc": "2.0",
40+
"id": 1,
41+
"result": {
42+
"capabilities": {
43+
"textDocumentSync": 2,
44+
"completionProvider": {
45+
"triggerCharacters": [".", ",", "'", "("],
46+
"resolveProvider": true
47+
}
48+
}
49+
}
50+
}
51+
]
52+
}
53+
},
54+
{
55+
"send": {
56+
"request": {
57+
"jsonrpc": "2.0",
58+
"method": "initialized",
59+
"params": {}
60+
},
61+
"wait": []
62+
}
63+
},
64+
{
65+
"send": {
66+
"request": {
67+
"jsonrpc": "2.0",
68+
"method": "textDocument/didOpen",
69+
"params": {
70+
"textDocument": {
71+
"uri": "$URI{main.adb}",
72+
"languageId": "ada",
73+
"version": 1,
74+
"text": "--\n--\n"
75+
}
76+
}
77+
},
78+
"wait": []
79+
}
80+
},
81+
{
82+
"send": {
83+
"request": {
84+
"jsonrpc": "2.0",
85+
"method": "workspace/didChangeConfiguration",
86+
"params": {
87+
"settings": {
88+
"ada": {
89+
"projectFile": "default.gpr"
90+
}
91+
}
92+
}
93+
},
94+
"wait": [
95+
{
96+
"method": "$/progress",
97+
"params": {
98+
"token": "<ANY>",
99+
"value": {
100+
"kind": "end"
101+
}
102+
}
103+
}
104+
]
105+
}
106+
},
107+
{
108+
"send": {
109+
"request": {
110+
"jsonrpc": "2.0",
111+
"method": "textDocument/didChange",
112+
"params": {
113+
"textDocument": {
114+
"uri": "$URI{main.adb}",
115+
"version": 2
116+
},
117+
"contentChanges": [
118+
{
119+
"range": {
120+
"start": {
121+
"line": 2,
122+
"character": 0
123+
},
124+
"end": {
125+
"line": 2,
126+
"character": 0
127+
}
128+
},
129+
"rangeLength": 0,
130+
"text": "p"
131+
}
132+
]
133+
}
134+
},
135+
"wait": []
136+
}
137+
},
138+
{
139+
"send": {
140+
"request": {
141+
"jsonrpc": "2.0",
142+
"id": 16,
143+
"method": "textDocument/completion",
144+
"params": {
145+
"textDocument": {
146+
"uri": "$URI{main.adb}"
147+
},
148+
"position": {
149+
"line": 2,
150+
"character": 1
151+
},
152+
"context": {
153+
"triggerKind": 1
154+
}
155+
}
156+
},
157+
"wait": [
158+
{
159+
"id": 16,
160+
"result": {
161+
"isIncomplete": false,
162+
"items": []
163+
}
164+
}
165+
]
166+
}
167+
},
168+
{
169+
"send": {
170+
"request": {
171+
"jsonrpc": "2.0",
172+
"id": 44,
173+
"method": "shutdown"
174+
},
175+
"wait": [
176+
{
177+
"id": 44,
178+
"result": null
179+
}
180+
]
181+
}
182+
},
183+
{
184+
"stop": {
185+
"exit_code": 0
186+
}
187+
}
188+
]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
title: 'completion.null_node'

0 commit comments

Comments
 (0)