Skip to content

Commit d6c63ab

Browse files
committed
fix: potential endless loop in GrammarRegistryManager.getGrammarFor
UI features using this lookup (e.g., presentation reconciler) can hang indefinitely when a content type is bound to a scope with no available grammar.
1 parent a168387 commit d6c63ab

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.io.InputStreamReader;
1818
import java.io.Reader;
1919
import java.net.URI;
20+
import java.nio.charset.StandardCharsets;
2021
import java.util.ArrayList;
2122
import java.util.Collection;
2223
import java.util.HashMap;
@@ -137,7 +138,7 @@ public URI getURI() {
137138

138139
@Override
139140
public Reader getReader() throws IOException {
140-
return new InputStreamReader(definition_.getInputStream());
141+
return new InputStreamReader(definition_.getInputStream(), StandardCharsets.UTF_8);
141142
}
142143

143144
@Override
@@ -161,6 +162,7 @@ public long getLastModified() {
161162
while (contentType != null) {
162163
final ContentTypeToScopeBinding binding = contentTypeToScopeBindings.get(contentType);
163164
if (binding == null) {
165+
// check parent content type
164166
contentType = contentType.getBaseType();
165167
continue;
166168
}
@@ -174,6 +176,9 @@ public long getLastModified() {
174176
grammar = getGrammarForScope(binding.scope.getName());
175177
if (grammar != null)
176178
return grammar;
179+
180+
// check parent content type
181+
contentType = contentType.getBaseType();
177182
}
178183
}
179184
return null;

0 commit comments

Comments
 (0)