diff --git a/CHANGELOG.md b/CHANGELOG.md index 175046b81..bbc2d034c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/README.md b/README.md index c5c5fa2b1..bec7de023 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package.json b/package.json index 7af6fb71f..1eb98b3bf 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/compile.ts b/src/compile.ts index 5d52863d1..3c900e881 100644 --- a/src/compile.ts +++ b/src/compile.ts @@ -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; diff --git a/src/extension.ts b/src/extension.ts index dc0e7806f..dfa6aa768 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -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.`); diff --git a/src/utilities.ts b/src/utilities.ts index 3c3fd1b82..39a1f84fc 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -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) {