Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Fix NPE when entering a hyperlink

AuthorDaveJarvis <email>
Date2023-04-10 18:15:10 GMT-0700
Commit5193db6fefd0e48abe96767fcd2bd434b36ee668
Parentd1cdf68
Delta16 lines added, 6 lines removed, 10-line increase
src/main/java/com/keenwrite/MainPane.java
public ProcessorContext createProcessorContext() {
- return createProcessorContext( null, NONE );
+ return createProcessorContextBuilder( NONE ).build();
+ }
+
+ private GenericBuilder<Mutator, ProcessorContext> createProcessorContextBuilder(
+ final ExportFormat format ) {
+ final var textEditor = getTextEditor();
+ final var sourcePath = textEditor.getPath();
+
+ return processorContextBuilder()
+ .with( Mutator::setSourcePath, sourcePath )
+ .with( Mutator::setExportFormat, format );
}
public ProcessorContext createProcessorContext(
final Path targetPath, final ExportFormat format ) {
- final var textEditor = getTextEditor();
- final var sourcePath = textEditor.getPath();
+ assert targetPath != null;
+ assert format != null;
+
+ final var builder = createProcessorContextBuilder( format );
- return processorContextBuilder()
- .with( Mutator::setSourcePath, sourcePath )
+ return builder
.with( Mutator::setTargetPath, targetPath )
- .with( Mutator::setExportFormat, format )
.build();
}