Skip to content

Commit

Permalink
Fix for semantic tokens highlight on only user specified files or def…
Browse files Browse the repository at this point in the history
…aults
  • Loading branch information
diyaayay committed May 17, 2024
1 parent d55c3a0 commit c266452
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion language-server/src/features/document-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DidChangeConfigurationNotification } from "vscode-languageserver";
import { publish } from "../pubsub.js";


export const isSchema = RegExp.prototype.test.bind(/(?:\.|\/|^)schema\.json$/);
export let schemaFilePatterns = ["**/*.schema.json", "**/schema.json"];

let hasConfigurationCapability = false;
Expand Down
5 changes: 3 additions & 2 deletions language-server/src/features/semantic-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { getKeywordId } from "@hyperjump/json-schema/experimental";
import * as Instance from "../json-instance.js";
import { getSchemaDocument } from "./schema-documents.js";
import { toAbsoluteUri } from "../util.js";
import { isSchema } from "./document-settings.js";
import { schemaFilePatterns } from "./document-settings.js";
import { isMatchedFile } from "./workspace.js";


export default {
Expand Down Expand Up @@ -51,7 +52,7 @@ export default {
};

connection.languages.semanticTokens.on(async ({ textDocument }) => {
if (!isSchema(textDocument.uri)) {
if (!isMatchedFile(textDocument.uri, schemaFilePatterns)) {
return { data: [] };
}

Expand Down
2 changes: 1 addition & 1 deletion language-server/src/features/workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { getDocumentSettings } from "./document-settings.js";
import picomatch from "picomatch";


const isMatchedFile = (uri, patterns) => {
export const isMatchedFile = (uri, patterns) => {
const matchers = patterns.map((pattern) => {
return picomatch(pattern, {
noglobstar: false,
Expand Down

0 comments on commit c266452

Please sign in to comment.