Skip to content

Commit

Permalink
(#18) Compile from active editor command.
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Feb 28, 2017
1 parent 90e5be2 commit f4e2b34
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.2.16] - 2017-02-28
### Added
- (#18) Compile from active editor command.

## [0.2.15] - 2017-02-19
### Changed
- (#14) Do not pop log panel with no log messages.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Alternatively, you can check out this repository and copy it to the VS Code loca
## Commands

- `latex-workshop.compile`: Compile LaTeX to PDF.
- `latex-workshop.compile_here`: Compile LaTeX to PDF from active editor.
- `latex-workshop.preview`: Open a live preview column for LaTeX.
- `latex-workshop.preview_browser`: Open a webpage preview for LaTeX.
- `latex-workshop.source`: Show LaTeX source of the preview.
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
"command": "latex-workshop.compile",
"title": "Compile LaTeX to PDF"
},
{
"command": "latex-workshop.compile_here",
"title": "Compile LaTeX to PDF from active editor"
},
{
"command": "latex-workshop.preview",
"title": "Show Preview"
Expand Down
4 changes: 2 additions & 2 deletions src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ var compiling = false,
to_compile = false,
prev_time = 0;

export async function compile() {
export async function compile(here = false) {
vscode.workspace.saveAll();
find_main_document();
find_main_document(here);
getPreviewPosition();

if (latex_data.main_document == undefined) return;
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export async function activate(context: vscode.ExtensionContext) {
const is_mac = process.platform === 'darwin';
has_compiler = hasbin.sync(configuration.get('compiler')) || is_mac;
context.subscriptions.push(
vscode.commands.registerCommand('latex-workshop.compile', has_compiler ? () => compile() : deactivated_feature)
vscode.commands.registerCommand('latex-workshop.compile', has_compiler ? () => compile() : deactivated_feature),
vscode.commands.registerCommand('latex-workshop.compile_here', has_compiler ? () => compile(true) : deactivated_feature)
);
if (!has_compiler) {
vscode.window.showWarningMessage(`LaTeX compiler ${configuration.get('compiler')} is not found.`);
Expand Down
3 changes: 2 additions & 1 deletion src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export function find_label_keys() {
latex_data.set_label_keys(keys);
}

export function find_main_document() {
export function find_main_document(here = false) {
if (here) latex_data.set_main_document(undefined);
if (latex_data.main_document != undefined) return;
var configuration = vscode.workspace.getConfiguration('latex-workshop');
if (configuration.get('main_document') != null) {
Expand Down

0 comments on commit f4e2b34

Please sign in to comment.