mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
Fix syntax highlighting when filename is quoted
Check if we have quotes and if so, remove them from the highlight.
This commit is contained in:
parent
63f989e6cf
commit
be2cb2dc72
1 changed files with 10 additions and 3 deletions
|
|
@ -87,20 +87,27 @@ export class SQLSealViewPlugin implements PluginValue {
|
|||
if (decorations) {
|
||||
decorations.forEach(dec => {
|
||||
if (dec.type === 'filename') {
|
||||
let hasQuotes = false;
|
||||
// Get the actual filename text from the document
|
||||
const filePath = view.state.doc.sliceString(
|
||||
let filePath = view.state.doc.sliceString(
|
||||
contentStart + dec.start,
|
||||
contentStart + dec.end
|
||||
);
|
||||
|
||||
// Remove leading & trailing quotes, if captured.
|
||||
if (filePath.startsWith('"')) {
|
||||
filePath = filePath.substring(1, filePath.length - 1)
|
||||
hasQuotes = true;
|
||||
}
|
||||
|
||||
// Create widget decoration for the filename
|
||||
const widget = new FilePathWidget(filePath, this.app);
|
||||
builder.push(Decoration.replace({
|
||||
widget,
|
||||
inclusive: true
|
||||
}).range(
|
||||
contentStart + dec.start,
|
||||
contentStart + dec.end
|
||||
contentStart + dec.start + Number(hasQuotes),
|
||||
contentStart + dec.end - Number(hasQuotes)
|
||||
));
|
||||
} else {
|
||||
const decoration = markDecorations[dec.type as keyof typeof markDecorations];
|
||||
|
|
|
|||
Loading…
Reference in a new issue