@@ -31,22 +31,26 @@ export function attach(connection: LanguageClientConnection): void {
31
31
* {@inheritDoc ShowDocumentParams}
32
32
*/
33
33
export async function showDocument ( params : ShowDocumentParams ) : Promise < ShowDocumentResult > {
34
- if ( ! params . external ) {
35
- // open using atom.workspace
36
- const view = await atom . workspace . open ( params . uri , {
37
- activateItem : params . takeFocus ,
38
- activatePane : params . takeFocus ,
39
- pending : true ,
40
- initialLine : params . selection ?. start . line ?? 0 ,
41
- initialColumn : params . selection ?. start . character ?? 0 ,
42
- } )
43
- if ( view instanceof TextEditor && params . selection !== undefined ) {
44
- view . selectToBufferPosition ( Convert . positionToPoint ( params . selection . end ) )
34
+ try {
35
+ if ( ! params . external ) {
36
+ // open using atom.workspace
37
+ const view = await atom . workspace . open ( params . uri , {
38
+ activateItem : params . takeFocus ,
39
+ activatePane : params . takeFocus ,
40
+ pending : true ,
41
+ initialLine : params . selection ?. start . line ?? 0 ,
42
+ initialColumn : params . selection ?. start . character ?? 0 ,
43
+ } )
44
+ if ( view instanceof TextEditor && params . selection !== undefined ) {
45
+ view . selectToBufferPosition ( Convert . positionToPoint ( params . selection . end ) )
46
+ }
47
+ } else {
48
+ // open using Electron
49
+ shell . openExternal ( params . uri , { activate : params . takeFocus } )
45
50
}
46
51
return { success : true }
47
- } else {
48
- // open using Electron
49
- shell . openExternal ( params . uri , { activate : params . takeFocus } )
50
- return { success : true }
52
+ } catch ( e ) {
53
+ atom . notifications . addError ( e )
54
+ return { success : false }
51
55
}
52
56
}
0 commit comments