Skip to content

Commit 096b855

Browse files
authored
fix(ui): revert notifications changes (#5484)
* Revert "fix(tests): update cases of cmdline message (#5468)" This reverts commit aa90971. * Revert "feat(notification)!: ensure that the ui notification is shown (#5447)" This reverts commit 8652e89. * chore(tests): increase case timeout * feat(ui): use echom for notifications
1 parent 97e6118 commit 096b855

23 files changed

+90
-76
lines changed

autoload/coc/ui.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function! coc#ui#echo_messages(hl, msgs)
166166
return
167167
endif
168168
execute 'echohl '.a:hl
169-
echo join(msgs, "\n")
169+
echom join(msgs, "\n")
170170
echohl None
171171
endfunction
172172

src/__tests__/completion/basic.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ describe('completion', () => {
11641164
await helper.waitPopup()
11651165
await helper.confirmCompletion(0)
11661166
await helper.waitFor('getline', ['.'], 'foo.bar')
1167-
})
1167+
}, 10000)
11681168

11691169
it('should should complete items without input', async () => {
11701170
await workspace.document

src/__tests__/completion/sources.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ describe('vim source', () => {
205205
it('should show error for bad source file', async () => {
206206
let filepath = createSourceFile('tmp', '')
207207
await sources.createVimSourceExtension(filepath)
208-
let res = await helper.doAction('notificationHistory')
209-
expect(res[res.length - 1].message).toMatch('Error')
208+
let line = await helper.getCmdline()
209+
expect(line).toMatch('Error')
210210
})
211211

212212
it('should register filetypes extension for vim source', async () => {

src/__tests__/core/files.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ describe('applyEdits()', () => {
150150
}
151151
let res = await workspace.applyEdit(workspaceEdit)
152152
expect(res).toBe(false)
153-
const notifications = await helper.doAction('notificationHistory')
154-
expect(notifications[notifications.length - 1].message).toMatch('Error')
153+
let line = await helper.getCmdline()
154+
expect(line).toMatch('Error')
155155
})
156156

157157
it('should apply TextEdit of documentChanges', async () => {

src/__tests__/handler/callHierarchy.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ describe('CallHierarchy', () => {
103103

104104
it('should show warning when provider does not exist', async () => {
105105
await helper.doAction('showIncomingCalls')
106-
let res = await helper.doAction('notificationHistory')
107-
expect(res[res.length - 1].message).toMatch('not found')
106+
let line = await helper.getCmdline()
107+
expect(line).toMatch('not found')
108108
})
109109

110110
it('should show message when no result returned.', async () => {
@@ -120,8 +120,8 @@ describe('CallHierarchy', () => {
120120
}
121121
}))
122122
await callHierarchy.showCallHierarchyTree('incoming')
123-
let res = await helper.doAction('notificationHistory')
124-
expect(res[res.length - 1].message).toMatch('Unable')
123+
let line = await helper.getCmdline()
124+
expect(line).toMatch('Unable')
125125
})
126126

127127
it('should render description and support default action', async () => {

src/__tests__/handler/codeActions.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ describe('handler codeActions', () => {
110110
await helper.createDocument()
111111
currActions = []
112112
await helper.doAction('codeActionRange', 1, 2, CodeActionKind.QuickFix)
113-
let res = await helper.doAction('notificationHistory')
114-
expect(res[res.length - 1].message).toMatch('No quickfix code action')
113+
let line = await helper.getCmdline()
114+
expect(line).toMatch(/No quickfix code action/)
115115
await helper.doAction('codeActionRange', 1, 2)
116-
res = await helper.doAction('notificationHistory')
117-
expect(res[res.length - 1].message).toMatch('No code action available')
116+
line = await helper.getCmdline()
117+
expect(line).toMatch(/No code action available/)
118118
})
119119

120120
it('should apply chosen action', async () => {
@@ -388,8 +388,8 @@ describe('handler codeActions', () => {
388388
await codeActions.doCodeAction(null, 'command', true)
389389
}).rejects.toThrow(Error)
390390
await codeActions.doCodeAction(null, 'cmd', true)
391-
let notifications = await helper.doAction('notificationHistory')
392-
expect(notifications[notifications.length - 1].message).toMatch('No cmd code action')
391+
let line = await helper.getCmdline()
392+
expect(line).toMatch('No cmd code action')
393393
})
394394

395395
it('should use quickpick', async () => {
@@ -415,8 +415,8 @@ describe('handler codeActions', () => {
415415
currActions = []
416416
await helper.createDocument()
417417
await helper.doAction('doQuickfix')
418-
let res = await helper.doAction('notificationHistory')
419-
expect(res[res.length - 1].message).toMatch('No quickfix')
418+
let msg = await helper.getCmdline()
419+
expect(msg).toMatch('No quickfix')
420420
})
421421

422422
it('should do preferred quickfix action', async () => {

src/__tests__/handler/codelens.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ describe('codeLenes feature', () => {
8484

8585
it('should toggle codeLens display', async () => {
8686
await codeLens.toggle(999)
87-
let notifications = await helper.doAction('notificationHistory')
88-
expect(notifications[notifications.length - 1].message).toMatch('not exists')
87+
let line = await helper.getCmdline()
88+
expect(line).toMatch('not exists')
8989
await createBufferWithCodeLens()
9090
await commands.executeCommand('document.toggleCodeLens')
9191
let doc = await workspace.document

src/__tests__/handler/documentColors.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,8 @@ describe('Colors', () => {
267267
it('should show warning when color does not exist', async () => {
268268
await helper.createDocument()
269269
await colors.pickPresentation()
270-
let res = await helper.doAction('notificationHistory')
271-
expect(res[res.length - 1].message).toMatch('Color not found')
270+
let msg = await helper.getCmdline()
271+
expect(msg).toMatch('Color not found')
272272
})
273273

274274
it('should not throw when presentations do not exist', async () => {
@@ -300,8 +300,8 @@ describe('Colors', () => {
300300
it('should show warning when color does not exist', async () => {
301301
await helper.createDocument()
302302
await colors.pickColor()
303-
let res = await helper.doAction('notificationHistory')
304-
expect(res[res.length - 1].message).toMatch('not found')
303+
let msg = await helper.getCmdline()
304+
expect(msg).toMatch('not found')
305305
})
306306

307307
it('should pickColor', async () => {

src/__tests__/handler/inlayHint.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@ describe('InlayHint', () => {
308308
it('should show message when inlayHint not supported', async () => {
309309
let doc = await workspace.document
310310
handler.setState('toggle', doc.bufnr)
311-
let res = await helper.doAction('notificationHistory')
312-
expect(res[res.length - 1].message).toMatch('not found')
311+
let cmdline = await helper.getCmdline()
312+
expect(cmdline).toMatch(/not\sfound/)
313313
})
314314

315315
it('should show message when not enabled', async () => {
@@ -318,8 +318,8 @@ describe('InlayHint', () => {
318318
let disposable = await registerProvider('')
319319
disposables.push(disposable)
320320
handler.setState('toggle', doc.bufnr)
321-
let res = await helper.doAction('notificationHistory')
322-
expect(res[res.length - 1].message).toMatch('not enabled')
321+
let cmdline = await helper.getCmdline()
322+
expect(cmdline).toMatch(/not\senabled/)
323323
})
324324

325325
it('should toggle inlayHints', async () => {

src/__tests__/handler/outline.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,8 @@ fun1() {}
385385
await nvim.command(`edit +setl\\ buftype=nofile t`)
386386
await workspace.document
387387
await symbols.showOutline(1)
388-
let res = await helper.doAction('notificationHistory')
389-
expect(res[res.length - 1].message).toMatch('Unable to show outline')
388+
let line = await helper.getCmdline()
389+
expect(line).toMatch('Unable to show outline')
390390
})
391391

392392
it('should not throw when provider does not exist', async () => {

0 commit comments

Comments
 (0)