Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,11 @@ The following settings are supported:
* `java.completion.engine`: [Experimental] Select code completion engine. Defaults to `ecj`.
* `java.references.includeDeclarations`: Include declarations when finding references. Defaults to `true`
* `java.jdt.ls.appcds.enabled` : [Experimental] Enable Java AppCDS (Application Class Data Sharing) for improvements to extension activation. When set to `auto`, AppCDS will be enabled in Visual Studio Code - Insiders, and for pre-release versions.

New in 1.50.0
* `java.hover.javadoc.enabled` : Enable/disable displaying Javadoc on hover. Defaults to `true`.

New in 1.53.0
* `java.updateImportsOnPaste.enabled` : Enable/disable auto organize imports when pasting code. Defaults to `true`.

Semantic Highlighting
===============
[Semantic Highlighting](https://github.com/redhat-developer/vscode-java/wiki/Semantic-Highlighting) fixes numerous syntax highlighting issues with the default Java Textmate grammar. However, you might experience a few minor issues, particularly a delay when it kicks in, as it needs to be computed by the Java Language server, when opening a new file or when typing. Semantic highlighting can be disabled for all languages using the `editor.semanticHighlighting.enabled` setting, or for Java only using [language-specific editor settings](https://code.visualstudio.com/docs/getstarted/settings#_languagespecific-editor-settings).
Expand Down
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,13 @@
"scope": "window",
"order": 20
},
"java.updateImportsOnPaste.enabled": {
"type": "boolean",
"default": true,
"description": "Enable/disable auto organize imports when pasting code",
"scope": "window",
"order": 25
},
"java.sources.organizeImports.starThreshold": {
"type": "integer",
"description": "Specifies the number of imports added before a star-import declaration is used.",
Expand Down
5 changes: 5 additions & 0 deletions src/pasteAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function registerCommands(languageClient: LanguageClient, context: Extens
}

export async function registerOrganizeImportsOnPasteCommand(): Promise<void> {

const clipboardText: string = await env.clipboard.readText();
const editor: TextEditor = window.activeTextEditor;
const documentText: string = editor.document.getText();
Expand All @@ -40,6 +41,10 @@ export async function registerOrganizeImportsOnPasteCommand(): Promise<void> {

action.then((wasApplied) => {
if (wasApplied && editor.document.languageId === "java") {
const updateImportsOnPasteEnabled = workspace.getConfiguration().get<boolean>("java.updateImportsOnPaste.enabled", true);
if (!updateImportsOnPasteEnabled) {
return;
}
const fileURI = editor.document.uri.toString();
const hasText: boolean = documentText !== null && /\S/.test(documentText);
if (hasText) {
Expand Down