-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add view meta XML command to switch quickly to the related meta…
… file
- Loading branch information
Showing
8 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/vscode-extension/src/commands/metadata/toggleMetaXmlCommand.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { VlocodeCommand } from '../../constants'; | ||
import * as vscode from 'vscode'; | ||
import MetadataCommand from './metadataCommand'; | ||
import { vscodeCommand } from '../../lib/commandRouter'; | ||
|
||
@vscodeCommand(VlocodeCommand.openMetaXml) | ||
@vscodeCommand(VlocodeCommand.openSourceFile) | ||
export default class ToggleMetaXmlCommand extends MetadataCommand { | ||
public execute() { | ||
if (!this.currentOpenDocument) { | ||
return; | ||
} | ||
|
||
if (this.currentOpenDocument.path.endsWith('-meta.xml')) { | ||
this.openSourceFile(this.currentOpenDocument); | ||
} else { | ||
this.openMetaXml(this.currentOpenDocument); | ||
} | ||
} | ||
|
||
private openMetaXml(documentUri: vscode.Uri) { | ||
const metaFile = documentUri.with({ | ||
path: documentUri.path + '-meta.xml' | ||
}); | ||
vscode.window.showTextDocument(metaFile); | ||
} | ||
|
||
private openSourceFile(documentUri: vscode.Uri) { | ||
const sourceFile = documentUri.with({ | ||
path: documentUri.path.slice(0, -'-meta.xml'.length) | ||
}); | ||
vscode.window.showTextDocument(sourceFile); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters