Skip to content

Commit

Permalink
Merge pull request #46 from ghostboats/show-line-content
Browse files Browse the repository at this point in the history
show content for files in localization folder on hover, otherwise show full line
  • Loading branch information
ghostboats authored May 15, 2024
2 parents 4e39d93 + f48dcbc commit 1c7ebf5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
22 changes: 15 additions & 7 deletions hovers/uuidsHandlesCollector.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,22 @@ function setupUuidsHandlesHoverProvider() {

const hoverText = instances.map(instance => {
const [relativePath, lineNum, lineContent] = instance.split('#');

// Extract the handle content inside the <content> tags, if any
const contentMatch = lineContent.match(/<content[^>]*>(.*?)<\/content>/);
let highlightedLineContent = contentMatch ? contentMatch[1] : '';

const openFileCommandUri = vscode.Uri.parse(`command:extension.openFileAtLine?${encodeURIComponent(JSON.stringify({ relativePath, lineNum }))}`);

let currentLine = `Content: ***${highlightedLineContent}*** \nFile: [${relativePath}](${openFileCommandUri}) \n--- \n`;
let currentLine;
const normalizedPath = relativePath.replace(/\\/g, '/').toLowerCase();
console.log(relativePath)
console.log(normalizedPath)
// Check if the file is within the Localization folder
if (normalizedPath.includes('localization/')) {
// Process as a localization-related file
const contentMatch = lineContent.match(/<content[^>]*>(.*?)<\/content>/);
let highlightedLineContent = contentMatch ? contentMatch[1] : '';
currentLine = `Loca Content: ***${highlightedLineContent}*** \nFile: [${relativePath}](${openFileCommandUri}) \n--- \n`;
} else {
let modifiedLineContent = lineContent.replace(/^<\/?|\/?>$/g, '');
let highlightedLineContent = modifiedLineContent.replace(/(id="[^"]*")/g, '**$1**');
currentLine = `Line: ${highlightedLineContent} \nFile: [**${relativePath}**](${openFileCommandUri}) \n--- \n`;
}
return currentLine;
}).join('\n');

Expand Down
2 changes: 1 addition & 1 deletion node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "bg3_mod_helper",
"publisher": "ghostboats",
"description": "This extension is designed to help you make mods in Baldur's Gate 3 by creating UUIDs and handles for you, as well as updating your .loca.xml files as well should they exist. And more to come in the future.",
"version": "2.1.32",
"version": "2.1.34",
"icon": "media/marketplace_icon.png",
"engines": {
"vscode": "^1.86.0"
Expand Down

0 comments on commit 1c7ebf5

Please sign in to comment.