asciidoctor-intellij-plugin icon indicating copy to clipboard operation
asciidoctor-intellij-plugin copied to clipboard

Refactor (move) images or includes does not update macro.

Open Alvis-pixel opened this issue 4 years ago • 3 comments

Let's say I have an image macro like the following:

image::image48.png[]

  • I want to move this image to a sub-folder (subdir) of the :imagesdir: location.
  • I place cursor on image name and press f6 (Refactor Move) and enter a new destination (subdir)
  • The image gets correctly moved to the new location.

I expect to see the macro updated to image::subdir/image48.png[].

The actual result is that the macro remains unchanged. This behavior also applies to the include directive.

AsciiDoc Plugin Version: 0.31.30

IDE Name and Version: IntelliJ 2020.2.2 (Community Edition)

Alvis-pixel avatar Sep 30 '20 09:09 Alvis-pixel

I guess this behaviour is intended.

And that corresponds with an issue I'm not really happy with. My main document includes chapters form a subfolder containing images from a subfolder on the same level. The preview of the main document shows all images perfectly. Biut editing the chapers the preview doesn't link the picturres because they reside in a folder one level above, Maybe this can be resolved processing the :imagesdir: Tag in the main document ...

src
|___images
     |_img.png
|___chapters
main.adoc //:imagesdir: images

pdiefent avatar Oct 01 '20 10:10 pdiefent

@pdiefent - the situation you describe is typical when chapters live in a sub-folder of the main document.

You could place a file .asciidoctorconfig in the folder chapters folder containing

:imagesdir: ../images

The plugin will prepend the contents of the .asciidoctorconfig file to each document in chapters, and the preview will be fixed.

See here for an example: https://github.com/ahus1/asciidoctor-deepdive/tree/master/images/imagesdir_config_with_relative_path

Read more about this feature in the plugin's documentation.

ahus1 avatar Oct 01 '20 17:10 ahus1

@Alvis-pixel - thanks for raising this issue. At the moment only Shift-F6 (rename file) is supported, not move.

I agree that it would be good if this would be supported.

Note to future self or contributor: AsciiDocFileReference will probably need to override bindToElement() to be triggered after the file rename. While the code change might be isolated to this class, knowing some ins and outs of IntelliJ SDK will prove helpful here.

ahus1 avatar Oct 01 '20 18:10 ahus1