File tree 2 files changed +31
-3
lines changed
sass_language_server/lib/src
sass_language_services/lib/src
2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,8 @@ class LanguageServer {
85
85
connection: _connection,
86
86
onDidChangeContent: (params) async {
87
87
try {
88
- // Reparse the stylesheet to update the cache with the new
89
- // version of the document.
90
- _ls.parseStylesheet (params.document);
88
+ // Update the cache with the new version of the document.
89
+ _ls.cache.onDocumentChanged (params.document);
91
90
if (initialScan != null ) {
92
91
await initialScan;
93
92
}
Original file line number Diff line number Diff line change @@ -46,6 +46,35 @@ class LanguageServicesCache {
46
46
return stylesheet;
47
47
}
48
48
49
+ sass.Stylesheet onDocumentChanged (TextDocument document) {
50
+ // We need this non-version checking method because of
51
+ // the rename feature. With that feature the client can
52
+ // send us "the first version" of a TextDocument after
53
+ // a rename, except we already have our own version 1
54
+ // from initial scan.
55
+
56
+ late final sass.Stylesheet stylesheet;
57
+ final languageId = document.languageId;
58
+ switch (languageId) {
59
+ case 'css' :
60
+ stylesheet = sass.Stylesheet .parseCss (document.getText ());
61
+ break ;
62
+ case 'scss' :
63
+ stylesheet = sass.Stylesheet .parseScss (document.getText ());
64
+ break ;
65
+ case 'sass' :
66
+ stylesheet = sass.Stylesheet .parseSass (document.getText ());
67
+ break ;
68
+ default :
69
+ throw 'Unsupported language ID $languageId ' ;
70
+ }
71
+
72
+ final key = document.uri.toString ();
73
+ _cache[key] = CacheEntry (document: document, stylesheet: stylesheet);
74
+
75
+ return stylesheet;
76
+ }
77
+
49
78
TextDocument ? getDocument (Uri uri) {
50
79
return _cache[uri.toString ()]? .document;
51
80
}
You can’t perform that action at this time.
0 commit comments