First steps in autocomplete - #5601
Conversation
|
|
||
| @injectable() | ||
| export class LanguageServer implements ILanguageServer { | ||
| private readonly startupCompleted: Deferred<void>; |
There was a problem hiding this comment.
@DonJayamme if you could take a look at this part, that'd be great. I think making this all a singleton makes sense. But not entirely sure.
There was a problem hiding this comment.
I think the LanguageServer was effectively a singleton before (as it's only created by the LanguageServerManager)
In reply to: 283065695 [](ancestors = 283065695)
| } | ||
|
|
||
| // Force the colors to the defaults | ||
| return null; |
There was a problem hiding this comment.
More of a question here. Why null for functions like this? As far as I'd seen the general though was always using undefined versus null unless specifically required by an external API. Want to make sure that we are both coding with the right concept of null versus undefined. #WontFix
There was a problem hiding this comment.
VSCode and Typescript compiler have a general undefined over null rule that they mostly stick to.
In reply to: 283067624 [](ancestors = 283067624)
There was a problem hiding this comment.
I think it's because some of the apis I was using were returning null colors.
In reply to: 283067624 [](ancestors = 283067624)
There was a problem hiding this comment.
Yeah not sure vscode returns undefined. I think they actually return null for a lot of stuff. At least the completion stuff did. I think 'null' means no value returned, as opposed to not sure if the function was called or not.
In reply to: 283067802 [](ancestors = 283067802,283067624)
There was a problem hiding this comment.
Yeah this says the same thing:
https://basarat.gitbooks.io/typescript/docs/javascript/null-undefined.html
Null and Undefined
Free youtube video on the subject
JavaScript (and by extension TypeScript) has two bottom types : null and undefined. They are intended to mean different things:
Something hasn't been initialized : undefined.
Something is currently unavailable: null.
In reply to: 283067961 [](ancestors = 283067961,283067802,283067624)
There was a problem hiding this comment.
If the APIs return it that's enough of a reason for me no need to change. Sounds like (in the second link) some VSCode folks want only undefined and some want to use it like the link you posted.
https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines#null-and-undefined
microsoft/vscode#70020
In reply to: 283068106 [](ancestors = 283068106,283067961,283067802,283067624)
There was a problem hiding this comment.
Here's another example:
node_modules\vscode-languageserver-protocol\lib\protocol.d.ts
returns '| null' on just about everything. There's no '| undefined' anywhere.
In reply to: 283068106 [](ancestors = 283068106,283067961,283067802,283067624)
There was a problem hiding this comment.
Oh it's DOM apis that return null. Looks like that's the root of where it comes from.
In reply to: 283068385 [](ancestors = 283068385,283068106,283067961,283067802,283067624)
| // https://github.com/Microsoft/vscode/blob/master/src/vs/editor/standalone/common/themes.ts#L13 | ||
| private generateMonacoThemeObject(args: IApplyThemeArgs) : monacoEditor.editor.IStandaloneThemeData { | ||
| const result: monacoEditor.editor.IStandaloneThemeData = { | ||
| base: args.isDark ? 'vs-dark' : 'vs', |
There was a problem hiding this comment.
Isn't it vs-light for the light theme? #Resolved
There was a problem hiding this comment.
Not in monaco. See this as an example:
https://microsoft.github.io/monaco-editor/playground.html#customizing-the-appearence-exposed-colors
In reply to: 283069004 [](ancestors = 283069004)
There was a problem hiding this comment.
Or this:
https://microsoft.github.io/monaco-editor/api/modules/monaco.editor.html#builtintheme
In reply to: 283069188 [](ancestors = 283069188,283069004)
| if (args.baseColors) { | ||
| const keys = Object.keys(args.baseColors); | ||
| keys.forEach(k => { | ||
| const color = args.baseColors && args.baseColors[k] ? args.baseColors[k] : '#000000'; |
There was a problem hiding this comment.
args.baseColors [](start = 30, length = 15)
Already checked at if #WontFix
There was a problem hiding this comment.
|
|
||
| // This theme may include others. If so we need to combine the two together | ||
| const include = theme ? theme.include : undefined; | ||
| if (include && include !== null) { |
There was a problem hiding this comment.
null should already be falsy. #Resolved
There was a problem hiding this comment.
| // Should be somewhere under currentPath/resources/app/extensions inside of a json file | ||
| let extensionsPath = path.join(currentPath, 'resources', 'app', 'extensions'); | ||
| if (!(await fs.pathExists(extensionsPath))) { | ||
| // Might be on mac or linux. try a different path |
There was a problem hiding this comment.
Don't we have an IsWindows that we use other places? #WontFix
There was a problem hiding this comment.
Yes, we do. But it still needs to check the first path I think.
In reply to: 283071695 [](ancestors = 283071695)
There was a problem hiding this comment.
I guess I'd feel more comfortable checking both.
In reply to: 283071819 [](ancestors = 283071819,283071695)
There was a problem hiding this comment.
| incomplete: list.isIncomplete | ||
| }; | ||
| } else { | ||
| const array = result as vscodeLanguageClient.CompletionItem[]; |
There was a problem hiding this comment.
If the result is a vscode.CompletionItem[] or vscode.CompletionList don't they both get cast as the array here? Or do they have the same property isIncomplete for the completion item and the completion list as the vscodeLanguageClient items? If so a comment would be nice to specify that. #Resolved
There was a problem hiding this comment.
Yes vscode.CompletionList and vcodeLanguageClient.CompletionList both have the isIncomplete property. This else should only come through here if the result is one of the two array types.
I'll add a comment to that effect.
In reply to: 283921359 [](ancestors = 283921359)
There was a problem hiding this comment.
Actually this is a good catch since one of those types isIncomplete is an optional parameter. It should be checking for 'items' instead.
In reply to: 283922093 [](ancestors = 283922093,283921359)
This is the history for this file in vscode: Refers to: resources/MagicPython.tmLanguage.json:2 in cfefcf0. [](commit_id = cfefcf0, deletion_comment = False) |
| private submitContent = () => { | ||
| let content = this.getContents(); | ||
| if (content) { | ||
| // Remove empty lines off the end |
There was a problem hiding this comment.
Does it make sense to trim leading new lines as well? #WontFix
There was a problem hiding this comment.
Maybe? I thought after was less obvious it was there so the user might not have intended it. On the front they did. But not sure why they'd want them. They just make the output cell bigger. Maybe somebody might do that on purpose though? Although I guess you could still achieve the same thing with a comment and bunch of space.
In reply to: 283932962 [](ancestors = 283932962)
| { | ||
| comments: { | ||
| lineComment: '#', | ||
| blockComment: ['\'\'\'', '\'\'\''] |
There was a problem hiding this comment.
doc comments are ''' or """ #Resolved
There was a problem hiding this comment.
These actually didn't seem to be used. I'll change it and see what happens. I think the tokenizer takes precedence.
In reply to: 283936732 [](ancestors = 283936732)
For #5342
Rewire everything to use monaco and provide suggestions and hover support. Just use the base language server for now (jedi or dotnetcore)
package-lock.jsonhas been regenerated by runningnpm install(if dependencies have changed)